Skip to content

Commit 1e9d6f0

Browse files
committed
Fix PR review changes.
1 parent f12c088 commit 1e9d6f0

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/main/java/org/java_websocket/client/WebSocketClient.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,10 @@ public WebSocketClient( URI serverUri , Draft protocolDraft , Map<String,String>
195195
}
196196
this.uri = serverUri;
197197
this.draft = protocolDraft;
198-
this.headers = httpHeaders;
198+
if(httpHeaders != null) {
199+
headers = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
200+
headers.putAll(httpHeaders);
201+
}
199202
this.connectTimeout = connectTimeout;
200203
setTcpNoDelay( false );
201204
setReuseAddr( false );
@@ -228,10 +231,13 @@ public Socket getSocket() {
228231
}
229232

230233
/**
234+
* @since 1.4.1
231235
* Adds an additional header to be sent in the handshake.<br>
232236
* If the connection is already made, adding headers has no effect,
233237
* unless reconnect is called, which then a new handshake is sent.<br>
234238
* If a header with the same key already exists, it is overridden.
239+
* @param key Name of the header to add.
240+
* @param value Value of the header to add.
235241
*/
236242
public void addHeader(String key, String value){
237243
if(headers == null)
@@ -240,7 +246,9 @@ public void addHeader(String key, String value){
240246
}
241247

242248
/**
249+
* @since 1.4.1
243250
* Removes a header from the handshake to be sent, if header key exists.<br>
251+
* @param key Name of the header to remove.
244252
* @return the previous value associated with key, or
245253
* null if there was no mapping for key.
246254
*/
@@ -251,6 +259,7 @@ public String removeHeader(String key) {
251259
}
252260

253261
/**
262+
* @since 1.4.1
254263
* Clears all previously put headers.
255264
*/
256265
public void clearHeaders() {

0 commit comments

Comments
 (0)