Class WsUpgrader
java.lang.Object
io.helidon.webserver.websocket.WsUpgrader
- All Implemented Interfaces:
Http1Upgrader
Http1Upgrader implementation to upgrade from HTTP/1.1 to WebSocket.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final HeaderNameWebsocket protocol header name.static final HeaderNameWebsocket protocol header name.protected static final StringSupported version.protected static final HeaderSupported version header.protected static final StringSwitching response prefix.protected static final StringSwitching response suffix.static final HeaderNameWebsocket key header name.static final HeaderNameWebsocket version header name. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanWhether no explicit origin allowlist is configured.static WsUpgraderWebSocket upgrader for HTTP/1.protected Stringhash(ConnectionContext ctx, String wsKey) Create the WebSocket accept hash.origins()Configured allowed origins.Expected value of the protocol upgrade, such ash2c, orwebsocket.upgrade(ConnectionContext ctx, HttpPrologue prologue, WritableHeaders<?> headers) Upgrade connection.
-
Field Details
-
WS_KEY
Websocket key header name. -
WS_VERSION
Websocket version header name. -
PROTOCOL
Websocket protocol header name. -
EXTENSIONS
Websocket protocol header name. -
SWITCHING_PROTOCOL_PREFIX
-
SWITCHING_PROTOCOLS_SUFFIX
-
SUPPORTED_VERSION
-
SUPPORTED_VERSION_HEADER
Supported version header.
-
-
Constructor Details
-
WsUpgrader
Create an upgrader.- Parameters:
wsConfig- WebSocket configuration
-
-
Method Details
-
create
WebSocket upgrader for HTTP/1.- Parameters:
config- configuration of web socket protocol- Returns:
- a new upgrader
-
supportedProtocol
Description copied from interface:Http1UpgraderExpected value of the protocol upgrade, such ash2c, orwebsocket. If an implementation supports multiple protocols, please implement this selector for each protocol- Specified by:
supportedProtocolin interfaceHttp1Upgrader- Returns:
- supported protocol
-
upgrade
public ServerConnection upgrade(ConnectionContext ctx, HttpPrologue prologue, WritableHeaders<?> headers) Description copied from interface:Http1UpgraderUpgrade connection.- Specified by:
upgradein interfaceHttp1Upgrader- Parameters:
ctx- connection contextprologue- http prologue of the upgrade requestheaders- http headers of the upgrade request- Returns:
- a new connection to use instead of the original
Http1Connection, ornullif the connection cannot be upgraded
-
anyOrigin
protected boolean anyOrigin()Whether no explicit origin allowlist is configured.- Returns:
- whether origin validation falls back to host authority matching
-
origins
-
hash
Create the WebSocket accept hash.- Parameters:
ctx- connection contextwsKey- WebSocket key- Returns:
- WebSocket accept hash
-