Skip to content

Commit 73faf7e

Browse files
committed
Merge pull request #65 from urish/patch-2
Make the `Sec-WebSocket-Protocol` header optional
2 parents 8988faf + 00be8c7 commit 73faf7e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/WebSocketsClient.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -397,9 +397,12 @@ void WebSocketsClient::sendHeader(WSclient_t * client) {
397397
"Connection: Upgrade\r\n"
398398
"User-Agent: arduino-WebSocket-Client\r\n"
399399
"Sec-WebSocket-Version: 13\r\n"
400-
"Sec-WebSocket-Protocol: " + client->cProtocol +"\r\n"
401400
"Sec-WebSocket-Key: " + client->cKey + "\r\n";
402401

402+
if(client->cProtocol.length() > 0) {
403+
handshake += "Sec-WebSocket-Protocol: " + client->cProtocol + "\r\n";
404+
}
405+
403406
if(client->cExtensions.length() > 0) {
404407
handshake += "Sec-WebSocket-Extensions: " + client->cExtensions + "\r\n";
405408
}

0 commit comments

Comments
 (0)