websockets / ws

Simple to use, blazing fast and thoroughly tested WebSocket client and server for Node.js
MIT License
21.6k stars 2.42k forks source link

Allow to configure handshake request headers #53

Closed chge closed 9 years ago

chge commented 12 years ago

It would be very helpful if ws.WebSocket implementation would allow to override/append HTTP request headers for handshake. For example, client may want to set custom headers with implementation-specific values, instead of sending them after handshake.

The RFC-6455 doesn't restrict this.

new WebSocket(
    'ws://example.com',
    {...
        headers: {
            'User-Agent': 'Node v0.7.7',
            'X-Custom-Authentication-Header': 'qwerty'
        }
    }
);
einaros commented 12 years ago

Feel free to pullreq ;)

Otherwise it'll be added eventually, but it's currently in the back of the line.

eagle21st commented 9 years ago

Hi,

I see the issue was posted almost three years ago, is the feature supported now? If so, is it documented anywhere?

Thanks,

glennschler commented 9 years ago

This issue has already been resolved in a previously merged commit which solved several related issues. Includes a passing test "Custom headers" in the test/WebSocket.test.js

commit 43a0b2b0277d64ffbb58e074b69cb9341923a3d2

I have been using this custom headers feature in my WS clients without issue, though before realizing this open issue.

3rd-Eden commented 9 years ago

Thanks for the heads up, seems like I missed this issue when closing a bunch of things.