Skip to content

Commit dc3c8ff

Browse files
authored
Merge pull request TooTallNate#503 from marci4/master
Append values if key already exists in handshake, fix for TooTallNate#269
2 parents 28e2fa6 + fa3c5c0 commit dc3c8ff

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,12 @@ public static HandshakeBuilder translateHandshakeHttp( ByteBuffer buf, Role role
134134
String[] pair = line.split( ":", 2 );
135135
if( pair.length != 2 )
136136
throw new InvalidHandshakeException( "not an http header" );
137-
handshake.put( pair[ 0 ], pair[ 1 ].replaceFirst( "^ +", "" ) );
137+
// If the handshake contains already a specific key, append the new value
138+
if ( handshake.hasFieldValue( pair[ 0 ] ) ) {
139+
handshake.put( pair[0], handshake.getFieldValue( pair[ 0 ] ) + "; " + pair[1].replaceFirst( "^ +", "" ) );
140+
} else {
141+
handshake.put( pair[0], pair[1].replaceFirst( "^ +", "" ) );
142+
}
138143
line = readStringLine( buf );
139144
}
140145
if( line == null )

0 commit comments

Comments
 (0)