Skip to content

Commit 05b9c25

Browse files
committed
Include whole invalid status line
When a InvalidHandShakeException is thrown, the whole invalid status line should be included
1 parent 7c34388 commit 05b9c25

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ bin
1515

1616
/doc
1717
*.xml
18-
.idea/.name
18+
.idea/.name
19+
*.jks

src/main/java/org/java_websocket/drafts/Draft.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,23 +119,24 @@ public static HandshakeBuilder translateHandshakeHttp( ByteBuffer buf, Role role
119119

120120
if( role == Role.CLIENT ) {
121121
// translating/parsing the response from the SERVER
122-
if (!"HTTP/1.1".equalsIgnoreCase(firstLineTokens[0])) {
123-
throw new InvalidHandshakeException( "Invalid status line received: " + firstLineTokens[0] );
124-
}
125122
if (!"101".equals(firstLineTokens[1])) {
126-
throw new InvalidHandshakeException( "Invalid status code received: " + firstLineTokens[1] );
123+
throw new InvalidHandshakeException( "Invalid status code received: " + firstLineTokens[1] + " Status line: " + line);
127124
}
125+
if (!"HTTP/1.1".equalsIgnoreCase(firstLineTokens[0])) {
126+
throw new InvalidHandshakeException( "Invalid status line received: " + firstLineTokens[0] + " Status line: " + line);
127+
}
128+
128129
handshake = new HandshakeImpl1Server();
129130
ServerHandshakeBuilder serverhandshake = (ServerHandshakeBuilder) handshake;
130131
serverhandshake.setHttpStatus( Short.parseShort( firstLineTokens[ 1 ] ) );
131132
serverhandshake.setHttpStatusMessage( firstLineTokens[ 2 ] );
132133
} else {
133134
// translating/parsing the request from the CLIENT
134135
if (!"GET".equalsIgnoreCase(firstLineTokens[0])) {
135-
throw new InvalidHandshakeException( "Invalid request method received: " + firstLineTokens[0] );
136+
throw new InvalidHandshakeException( "Invalid request method received: " + firstLineTokens[0] + " Status line: " + line);
136137
}
137138
if (!"HTTP/1.1".equalsIgnoreCase(firstLineTokens[2])) {
138-
throw new InvalidHandshakeException( "Invalid status line received: " + firstLineTokens[2] );
139+
throw new InvalidHandshakeException( "Invalid status line received: " + firstLineTokens[2] + " Status line: " + line);
139140
}
140141
ClientHandshakeBuilder clienthandshake = new HandshakeImpl1Client();
141142
clienthandshake.setResourceDescriptor( firstLineTokens[ 1 ] );

0 commit comments

Comments
 (0)