Skip to content

WebSocket connection failing due to "Upgrade" header value case sensitivity #875

@HusamElbashir

Description

@HusamElbashir

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:

  1. An |Upgrade| header field containing the value "websocket",
    treated as an ASCII case-insensitive value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions