Class WebSocketServerProtocolConfig.Builder
- java.lang.Object
-
- io.netty.handler.codec.http.websocketx.WebSocketServerProtocolConfig.Builder
-
- Enclosing class:
- WebSocketServerProtocolConfig
public static final class WebSocketServerProtocolConfig.Builder extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Set<java.lang.String>allowedOriginsprivate booleancheckStartsWithprivate WebSocketDecoderConfigdecoderConfigprivate WebSocketDecoderConfig.BuilderdecoderConfigBuilderprivate booleandropPongFramesprivate longforceCloseTimeoutMillisprivate booleanhandleCloseFramesprivate longhandshakeTimeoutMillisprivate WebSocketCloseStatussendCloseFrameprivate java.lang.Stringsubprotocolsprivate java.lang.StringwebsocketPath
-
Constructor Summary
Constructors Modifier Constructor Description privateBuilder(WebSocketServerProtocolConfig serverConfig)privateBuilder(java.lang.String websocketPath, java.lang.String subprotocols, boolean checkStartsWith, long handshakeTimeoutMillis, long forceCloseTimeoutMillis, boolean handleCloseFrames, WebSocketCloseStatus sendCloseFrame, boolean dropPongFrames, WebSocketDecoderConfig decoderConfig, java.util.Set<java.lang.String> allowedOrigins)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WebSocketServerProtocolConfig.BuilderallowedOrigins(java.lang.String... allowedOrigins)The origins (for examplehttps://example.comorhttp://localhost:8080) that are allowed to open a WebSocket connection.WebSocketServerProtocolConfig.BuilderallowedOrigins(java.util.Collection<java.lang.String> allowedOrigins)WebSocketServerProtocolConfig.BuilderallowExtensions(boolean allowExtensions)WebSocketServerProtocolConfig.BuilderallowMaskMismatch(boolean allowMaskMismatch)WebSocketServerProtocolConfigbuild()Build unmodifiable server protocol configuration.WebSocketServerProtocolConfig.BuildercheckStartsWith(boolean checkStartsWith)trueto handle all requests, where URI path component starts fromWebSocketServerProtocolConfig.websocketPath(),falsefor exact match (default).WebSocketServerProtocolConfig.BuildercloseOnProtocolViolation(boolean closeOnProtocolViolation)WebSocketServerProtocolConfig.BuilderdecoderConfig(WebSocketDecoderConfig decoderConfig)Frames decoder configuration.private WebSocketDecoderConfig.BuilderdecoderConfigBuilder()WebSocketServerProtocolConfig.BuilderdropPongFrames(boolean dropPongFrames)trueif pong frames should not be forwardedWebSocketServerProtocolConfig.BuilderexpectMaskedFrames(boolean expectMaskedFrames)WebSocketServerProtocolConfig.BuilderforceCloseTimeoutMillis(long forceCloseTimeoutMillis)Close the connection if it was not closed by the client after timeout specifiedWebSocketServerProtocolConfig.BuilderhandleCloseFrames(boolean handleCloseFrames)trueif close frames should not be forwarded and just close the channelWebSocketServerProtocolConfig.BuilderhandshakeTimeoutMillis(long handshakeTimeoutMillis)Handshake timeout in mills, when handshake timeout, will trigger user eventWebSocketClientProtocolHandler.ClientHandshakeStateEvent.HANDSHAKE_TIMEOUTWebSocketServerProtocolConfig.BuildermaxFramePayloadLength(int maxFramePayloadLength)WebSocketServerProtocolConfig.BuildersendCloseFrame(WebSocketCloseStatus sendCloseFrame)Close frame to send, when close frame was not send manually.WebSocketServerProtocolConfig.Buildersubprotocols(java.lang.String subprotocols)CSV of supported protocolsWebSocketServerProtocolConfig.BuilderwebsocketPath(java.lang.String websocketPath)URI path component to handle websocket upgrade requests on.WebSocketServerProtocolConfig.BuilderwithUTF8Validator(boolean withUTF8Validator)
-
-
-
Field Detail
-
websocketPath
private java.lang.String websocketPath
-
subprotocols
private java.lang.String subprotocols
-
checkStartsWith
private boolean checkStartsWith
-
handshakeTimeoutMillis
private long handshakeTimeoutMillis
-
forceCloseTimeoutMillis
private long forceCloseTimeoutMillis
-
handleCloseFrames
private boolean handleCloseFrames
-
sendCloseFrame
private WebSocketCloseStatus sendCloseFrame
-
dropPongFrames
private boolean dropPongFrames
-
decoderConfig
private WebSocketDecoderConfig decoderConfig
-
decoderConfigBuilder
private WebSocketDecoderConfig.Builder decoderConfigBuilder
-
allowedOrigins
private java.util.Set<java.lang.String> allowedOrigins
-
-
Constructor Detail
-
Builder
private Builder(WebSocketServerProtocolConfig serverConfig)
-
Builder
private Builder(java.lang.String websocketPath, java.lang.String subprotocols, boolean checkStartsWith, long handshakeTimeoutMillis, long forceCloseTimeoutMillis, boolean handleCloseFrames, WebSocketCloseStatus sendCloseFrame, boolean dropPongFrames, WebSocketDecoderConfig decoderConfig, java.util.Set<java.lang.String> allowedOrigins)
-
-
Method Detail
-
websocketPath
public WebSocketServerProtocolConfig.Builder websocketPath(java.lang.String websocketPath)
URI path component to handle websocket upgrade requests on.
-
subprotocols
public WebSocketServerProtocolConfig.Builder subprotocols(java.lang.String subprotocols)
CSV of supported protocols
-
checkStartsWith
public WebSocketServerProtocolConfig.Builder checkStartsWith(boolean checkStartsWith)
trueto handle all requests, where URI path component starts fromWebSocketServerProtocolConfig.websocketPath(),falsefor exact match (default).
-
handshakeTimeoutMillis
public WebSocketServerProtocolConfig.Builder handshakeTimeoutMillis(long handshakeTimeoutMillis)
Handshake timeout in mills, when handshake timeout, will trigger user eventWebSocketClientProtocolHandler.ClientHandshakeStateEvent.HANDSHAKE_TIMEOUT
-
forceCloseTimeoutMillis
public WebSocketServerProtocolConfig.Builder forceCloseTimeoutMillis(long forceCloseTimeoutMillis)
Close the connection if it was not closed by the client after timeout specified
-
handleCloseFrames
public WebSocketServerProtocolConfig.Builder handleCloseFrames(boolean handleCloseFrames)
trueif close frames should not be forwarded and just close the channel
-
sendCloseFrame
public WebSocketServerProtocolConfig.Builder sendCloseFrame(WebSocketCloseStatus sendCloseFrame)
Close frame to send, when close frame was not send manually. Ornullto disable proper close.
-
dropPongFrames
public WebSocketServerProtocolConfig.Builder dropPongFrames(boolean dropPongFrames)
trueif pong frames should not be forwarded
-
decoderConfig
public WebSocketServerProtocolConfig.Builder decoderConfig(WebSocketDecoderConfig decoderConfig)
Frames decoder configuration.
-
allowedOrigins
public WebSocketServerProtocolConfig.Builder allowedOrigins(java.lang.String... allowedOrigins)
The origins (for examplehttps://example.comorhttp://localhost:8080) that are allowed to open a WebSocket connection. Origins are compared case-insensitively against theOriginrequest header (and theSec-WebSocket-Originheader used by the older hybi-07 and hybi-08 protocol versions), which must match exactly (scheme, host and port). Handshake requests carrying an origin that is not allowed are rejected with403 Forbiddenand the connection is closed.Requests without an
OriginorSec-WebSocket-Originheader are not subject to this check, as they do not originate from a browser (which always sends the header on WebSocket handshakes).If not configured (the default) the
Originheader is not validated. Applications that rely on ambient credentials such as cookies must configure this to prevent Cross-Site WebSocket Hijacking.- Parameters:
allowedOrigins- the allowed origins, must not be empty.
-
allowedOrigins
public WebSocketServerProtocolConfig.Builder allowedOrigins(java.util.Collection<java.lang.String> allowedOrigins)
- Parameters:
allowedOrigins- the allowed origins, must not be empty.
-
decoderConfigBuilder
private WebSocketDecoderConfig.Builder decoderConfigBuilder()
-
maxFramePayloadLength
public WebSocketServerProtocolConfig.Builder maxFramePayloadLength(int maxFramePayloadLength)
-
expectMaskedFrames
public WebSocketServerProtocolConfig.Builder expectMaskedFrames(boolean expectMaskedFrames)
-
allowMaskMismatch
public WebSocketServerProtocolConfig.Builder allowMaskMismatch(boolean allowMaskMismatch)
-
allowExtensions
public WebSocketServerProtocolConfig.Builder allowExtensions(boolean allowExtensions)
-
closeOnProtocolViolation
public WebSocketServerProtocolConfig.Builder closeOnProtocolViolation(boolean closeOnProtocolViolation)
-
withUTF8Validator
public WebSocketServerProtocolConfig.Builder withUTF8Validator(boolean withUTF8Validator)
-
build
public WebSocketServerProtocolConfig build()
Build unmodifiable server protocol configuration.
-
-