Skip to content

Commit

Permalink
Fix PR review changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
haruntuncay committed Apr 7, 2019
1 parent f12c088 commit 1e9d6f0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main/java/org/java_websocket/client/WebSocketClient.java
Expand Up @@ -195,7 +195,10 @@ public WebSocketClient( URI serverUri , Draft protocolDraft , Map<String,String>
}
this.uri = serverUri;
this.draft = protocolDraft;
this.headers = httpHeaders;
if(httpHeaders != null) {
headers = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
headers.putAll(httpHeaders);
}
this.connectTimeout = connectTimeout;
setTcpNoDelay( false );
setReuseAddr( false );
Expand Down Expand Up @@ -228,10 +231,13 @@ public Socket getSocket() {
}

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

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

/**
* @since 1.4.1
* Clears all previously put headers.
*/
public void clearHeaders() {
Expand Down

0 comments on commit 1e9d6f0

Please sign in to comment.