The WebSocket interface specified by W3C and available in browsers doesn't allow to set request headers but in some cases request headers are used and can be configured. For example, subprotocol names are transmitted through Sec-WebSocket-Protocol header field. Also, this restriction is only valid in browser-based applications.
This feature allows to read WebSocket handshake request headers without unwrapping a ServerWebSocket instance to access underlying objects so that a developer should be able to retrieve headers such as Authorization and Sec-WebSocket-Protocol and use them to implement some protocol.
The following methods will be added in ServerWebSocket as handshake request header accessors:
Set<String> headerNames();
String header(String name);
List<String> headers(String name);
The WebSocket interface specified by W3C and available in browsers doesn't allow to set request headers but in some cases request headers are used and can be configured. For example, subprotocol names are transmitted through
Sec-WebSocket-Protocolheader field. Also, this restriction is only valid in browser-based applications.This feature allows to read WebSocket handshake request headers without unwrapping a
ServerWebSocketinstance to access underlying objects so that a developer should be able to retrieve headers such asAuthorizationandSec-WebSocket-Protocoland use them to implement some protocol.The following methods will be added in
ServerWebSocketas handshake request header accessors:Set<String> headerNames();String header(String name);List<String> headers(String name);