FullHttpResponse() — netty Function Reference
Architecture documentation for the FullHttpResponse() function in WebSocketServerHandshaker13.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD dfefc2e4_7319_4560_00c4_f148515b859b["FullHttpResponse()"] 5215fe90_7a02_a4cb_af67_a3e5f8d6ec14["WebSocketServerHandshaker13"] dfefc2e4_7319_4560_00c4_f148515b859b -->|defined in| 5215fe90_7a02_a4cb_af67_a3e5f8d6ec14 style dfefc2e4_7319_4560_00c4_f148515b859b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker13.java lines 137–191
@Override
protected FullHttpResponse newHandshakeResponse(FullHttpRequest req, HttpHeaders headers) {
HttpMethod method = req.method();
if (!GET.equals(method)) {
throw new WebSocketServerHandshakeException("Invalid WebSocket handshake method: " + method, req);
}
HttpHeaders reqHeaders = req.headers();
if (!reqHeaders.contains(HttpHeaderNames.CONNECTION) ||
!reqHeaders.containsValue(HttpHeaderNames.CONNECTION, HttpHeaderValues.UPGRADE, true)) {
throw new WebSocketServerHandshakeException(
"not a WebSocket request: a |Connection| header must includes a token 'Upgrade'", req);
}
if (!reqHeaders.contains(HttpHeaderNames.UPGRADE, HttpHeaderValues.WEBSOCKET, true)) {
throw new WebSocketServerHandshakeException(
"not a WebSocket request: a |Upgrade| header must containing the value 'websocket'", req);
}
CharSequence key = reqHeaders.get(HttpHeaderNames.SEC_WEBSOCKET_KEY);
if (key == null) {
throw new WebSocketServerHandshakeException("not a WebSocket request: missing key", req);
}
FullHttpResponse res = new DefaultFullHttpResponse(HTTP_1_1, HttpResponseStatus.SWITCHING_PROTOCOLS,
req.content().alloc().buffer(0));
if (headers != null) {
res.headers().add(headers);
}
String acceptSeed = key + WEBSOCKET_13_ACCEPT_GUID;
byte[] sha1 = WebSocketUtil.sha1(acceptSeed.getBytes(CharsetUtil.US_ASCII));
String accept = WebSocketUtil.base64(sha1);
if (logger.isDebugEnabled()) {
logger.debug("WebSocket version 13 server handshake key: {}, response: {}", key, accept);
}
res.headers().set(HttpHeaderNames.UPGRADE, HttpHeaderValues.WEBSOCKET)
.set(HttpHeaderNames.CONNECTION, HttpHeaderValues.UPGRADE)
.set(HttpHeaderNames.SEC_WEBSOCKET_ACCEPT, accept);
String subprotocols = reqHeaders.get(HttpHeaderNames.SEC_WEBSOCKET_PROTOCOL);
if (subprotocols != null) {
String selectedSubprotocol = selectSubprotocol(subprotocols);
if (selectedSubprotocol == null) {
if (logger.isDebugEnabled()) {
logger.debug("Requested subprotocol(s) not supported: {}", subprotocols);
}
} else {
res.headers().set(HttpHeaderNames.SEC_WEBSOCKET_PROTOCOL, selectedSubprotocol);
}
}
return res;
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does FullHttpResponse() do?
FullHttpResponse() is a function in the netty codebase, defined in codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker13.java.
Where is FullHttpResponse() defined?
FullHttpResponse() is defined in codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker13.java at line 137.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free