Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

Websocket - support for custom headers for handshake

  • பதில்கள் இல்லை
  • 3 இந்த பிரச்னைகள் உள்ளது
  • 66 views

please consider adding ability to add custom headers for handshake. In RFC6455 there one interesting point:

The request MAY include any other header fields, for example, cookies [RFC6265] and/or authentication-related header fields such as the |Authorization| header field [RFC2616], which are processed according to documents that define them. I've found an example how to add custom header to handshake: https://blog.heckel.xyz/2014/10/30/http-basic-auth-for-websocket-connections-with-undertow/ but this is for Java and unfortunately isn't possible in HTML5.

When searching over the net I found many places question about this option, for example: sta/websocket-sharp#22 https://stackoverflow.com/questions/4361173/http-headers-in-websockets-client-api/4361358#4361358 aspnet/SignalR#888

For example in Python this is possible https://stackoverflow.com/questions/15381414/sending-custom-headers-in-websocket-handshake. Other languages also support this. Last place missing is the browser.

Currently setting custom headers isn't supported in Firefox, as it isn't part of any standard (is is part of RFC 6455 but not part of WHATWG). I've filled feature request in WHATWG (https://github.com/whatwg/html/issues/3062) but I was asked to create feature requests for each main browser. Having Your interest this feature could be added to standard.

please consider adding ability to add custom headers for handshake. In RFC6455 there one interesting point: The request MAY include any other header fields, for example, cookies [RFC6265] and/or authentication-related header fields such as the |Authorization| header field [RFC2616], which are processed according to documents that define them. I've found an example how to add custom header to handshake: https://blog.heckel.xyz/2014/10/30/http-basic-auth-for-websocket-connections-with-undertow/ but this is for Java and unfortunately isn't possible in HTML5. When searching over the net I found many places question about this option, for example: sta/websocket-sharp#22 https://stackoverflow.com/questions/4361173/http-headers-in-websockets-client-api/4361358#4361358 aspnet/SignalR#888 For example in Python this is possible https://stackoverflow.com/questions/15381414/sending-custom-headers-in-websocket-handshake. Other languages also support this. Last place missing is the browser. Currently setting custom headers isn't supported in Firefox, as it isn't part of any standard (is is part of RFC 6455 but not part of WHATWG). I've filled feature request in WHATWG (https://github.com/whatwg/html/issues/3062) but I was asked to create feature requests for each main browser. Having Your interest this feature could be added to standard.