allow any "case" for Upgrade

RFC6455:
An |Upgrade| header field containing the value "websocket", treated as an ASCII case-insensitive value.
This commit is contained in:
Markus Sattler
2015-06-17 10:37:20 +02:00
parent f118a13d0f
commit 28b7619419
2 changed files with 14 additions and 8 deletions

View File

@ -319,10 +319,13 @@ void WebSocketsClient::handleHeader(WSclient_t * client) {
client->cCode = headerLine.substring(9, headerLine.indexOf(' ', 9)).toInt(); client->cCode = headerLine.substring(9, headerLine.indexOf(' ', 9)).toInt();
} else if(headerLine == "Connection: Upgrade") { } else if(headerLine == "Connection: Upgrade") {
client->cIsUpgrade = true; client->cIsUpgrade = true;
} else if(headerLine == "Upgrade: websocket") { } else if(headerLine.startsWith("Upgrade: ")) {
client->cIsWebsocket = true; // 9 = lenght of "Upgrade: "
} else if(headerLine == "Upgrade: WebSocket") { String low = headerLine.substring(9);
low.toLowerCase();
if(low == "websocket") {
client->cIsWebsocket = true; client->cIsWebsocket = true;
}
} else if(headerLine.startsWith("Sec-WebSocket-Accept: ")) { } else if(headerLine.startsWith("Sec-WebSocket-Accept: ")) {
// 22 = lenght of "Sec-WebSocket-Accept: " // 22 = lenght of "Sec-WebSocket-Accept: "
client->cAccept = headerLine.substring(22); client->cAccept = headerLine.substring(22);

View File

@ -404,10 +404,13 @@ void WebSocketsServer::handleHeader(WSclient_t * client) {
client->cUrl = headerLine.substring(4, headerLine.indexOf(' ', 4)); client->cUrl = headerLine.substring(4, headerLine.indexOf(' ', 4));
} else if(headerLine == "Connection: Upgrade") { } else if(headerLine == "Connection: Upgrade") {
client->cIsUpgrade = true; client->cIsUpgrade = true;
} else if(headerLine == "Upgrade: websocket") { } else if(headerLine.startsWith("Upgrade: ")) {
client->cIsWebsocket = true; // 9 = lenght of "Upgrade: "
} else if(headerLine == "Upgrade: WebSocket") { String low = headerLine.substring(9);
low.toLowerCase();
if(low == "websocket") {
client->cIsWebsocket = true; client->cIsWebsocket = true;
}
} else if(headerLine.startsWith("Sec-WebSocket-Version: ")) { } else if(headerLine.startsWith("Sec-WebSocket-Version: ")) {
// 23 = lenght of "Sec-WebSocket-Version: " // 23 = lenght of "Sec-WebSocket-Version: "
client->cVersion = headerLine.substring(23).toInt(); client->cVersion = headerLine.substring(23).toInt();