I'm encountering an issue with an iOS client that fails to establish a WebSocket connection to my Hono server. The problem lies in the upgradeWebSocket function, which is unnecessarily case-sensitive to the value of the Upgrade header. Specifically, the client sends the value WebSocket as part of the handshake, and the server rejects it.
async function upgradeWebSocket(c, next) {
if (c.req.header('upgrade') !== 'websocket') {
// Not websocket
await next()
return
}
However per RFC 6455 Section 4.2.1 this header's value should be treated as case-insensitive:
- An |Upgrade| header field containing the value "websocket",
treated as an ASCII case-insensitive value.
I'm encountering an issue with an iOS client that fails to establish a WebSocket connection to my Hono server. The problem lies in the
upgradeWebSocketfunction, which is unnecessarily case-sensitive to the value of theUpgradeheader. Specifically, the client sends the valueWebSocketas part of the handshake, and the server rejects it.However per RFC 6455 Section 4.2.1 this header's value should be treated as case-insensitive: