paullouisageneau / libdatachannel

C/C++ WebRTC network library featuring Data Channels, Media Transport, and WebSockets
https://libdatachannel.org/
Mozilla Public License 2.0
1.82k stars 365 forks source link

[websockets] Upgrade header value case sensitive #276

Closed hhgyu closed 4 years ago

hhgyu commented 4 years ago

When testing websocket support, I found that the Upgrade header value is treated as case sensitive.

https://github.com/paullouisageneau/libdatachannel/blob/5482912e18f64f67863a8769de6056787158c758/src/wstransport.cpp#L217-L231

https://github.com/warmcat/libwebsockets/blob/main/lib/roles/ws/server-ws.c#L689

    LWS_CPYAPP(p, "HTTP/1.1 101 Switching Protocols\x0d\x0a"
              "Upgrade: WebSocket\x0d\x0a"
              "Connection: Upgrade\x0d\x0a"
              "Sec-WebSocket-Accept: ");

RFC6455 always uses websocket as value, but Section 11.2 registers WebSocket as Upgrade keyword.

paullouisageneau commented 4 years ago

Indeed, thanks for testing! This is fixed by https://github.com/paullouisageneau/libdatachannel/pull/277