skaarj1989 / mWebSockets

WebSockets for microcontrollers
https://skaarj1989.github.io/mWebSockets/autobahn-testsuite/servers/
MIT License
108 stars 23 forks source link

Support for case insensitive HTTP Headers #30

Closed prenone closed 3 years ago

prenone commented 3 years ago

Per RFC 2616 HTTP headers (both keys and values) are case-insensitive. Changing strcmp_P to strcasecmp_P in WebSocketClient::_readResponse() makes it compliant.

I personally had an issue when placing NGINX proxy between a WebSocket client (mWebSockets) and a WebSocket server (ws) because NGINX normalizes every header (key and value) to be lower case. I suspect that there are many more incompatible WebSocket servers

Note: strcasecmp_P was already in use for the Upgrade header value.

The library was tested and the connection was successfully established with the aforementioned NGINX proxy in place. The WebSocket connection should also be working fine as I didn't touch any of it, but I didn't actually test it thoroughly.

I also made analogous changes in WebSocketServer. I did not test it, but personally I think it is not necessary and should work fine.

prenone commented 3 years ago

I just noticed issue #27 which is the exact issue I had. This fixes it.

skaarj1989 commented 3 years ago

Hi @prenone On Page 20 (...) all header field names in both HTTP requests and HTTP responses are case-insensitive. Somehow i missed this statement in documentation.

Thank you for fixing it.