Skip to content

Setting custom headers on initial WebSocket HTTP Upgrade response #204

Open
@bahamut657

Description

@bahamut657

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the feature has not already been requested

🚀 Feature Proposal

I'm building an HTTP reverse proxy using fastify.
In order to support other 3rd parts WebSocket connections, proxied by my software, I need a way to rewrite headers obtained in UPGRADE response from the replicated WS connection.
Is there a way to write some custom header in the initial upgrade request?

Example

In my case I have to replicate this headers:

Connection: upgrade
Content-Type: application/octet-stream
Date: Tue, 24 May 2022 16:19:40 GMT
Sec-WebSocket-Accept: MGhCOJFY8ayJUf3cJ+BcSgTwOOg=
Sec-WebSocket-Extensions: permessage-deflate
Sec-WebSocket-Protocol: tty
Server: Python/3.9 aiohttp/3.8.1
Upgrade: websocket

But from the reverse proxy I obtain this response:

Connection: Upgrade
Sec-WebSocket-Accept: 0hWXq3owSgRUjfyWd9dJpW6+lm0=
Sec-WebSocket-Protocol: tty
Upgrade: websocket

I have some missing fields and one to rewrite

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