decodeLast() — netty Function Reference
Architecture documentation for the decodeLast() function in HttpObjectDecoder.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD ac7d1180_2220_c6a4_43ef_f0127601fbf9["decodeLast()"] 6c551372_1bb2_fe27_3884_c4cc297c86ae["HttpObjectDecoder"] ac7d1180_2220_c6a4_43ef_f0127601fbf9 -->|defined in| 6c551372_1bb2_fe27_3884_c4cc297c86ae c3ede65f_ecbf_6fbd_c4d2_9a1fcb90c682["resetNow()"] ac7d1180_2220_c6a4_43ef_f0127601fbf9 -->|calls| c3ede65f_ecbf_6fbd_c4d2_9a1fcb90c682 e8aadc10_5550_f709_7873_e84704f04e88["isDecodingRequest()"] ac7d1180_2220_c6a4_43ef_f0127601fbf9 -->|calls| e8aadc10_5550_f709_7873_e84704f04e88 style ac7d1180_2220_c6a4_43ef_f0127601fbf9 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectDecoder.java lines 559–615
@Override
protected void decodeLast(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
super.decodeLast(ctx, in, out);
if (resetRequested.get()) {
// If a reset was requested by decodeLast() we need to do it now otherwise we may produce a
// LastHttpContent while there was already one.
resetNow();
}
// Handle the last unfinished message.
switch (currentState) {
case READ_VARIABLE_LENGTH_CONTENT:
if (!chunked && !in.isReadable()) {
// End of connection.
out.add(LastHttpContent.EMPTY_LAST_CONTENT);
resetNow();
}
return;
case READ_HEADER:
// If we are still in the state of reading headers we need to create a new invalid message that
// signals that the connection was closed before we received the headers.
out.add(invalidMessage(message, Unpooled.EMPTY_BUFFER,
new PrematureChannelClosureException("Connection closed before received headers")));
resetNow();
return;
case READ_CHUNK_DELIMITER: // fall-trough
case READ_CHUNK_FOOTER: // fall-trough
case READ_CHUNKED_CONTENT: // fall-trough
case READ_CHUNK_SIZE: // fall-trough
case READ_FIXED_LENGTH_CONTENT:
// Check if the closure of the connection signifies the end of the content.
boolean prematureClosure;
if (isDecodingRequest() || chunked) {
// The last request did not wait for a response.
prematureClosure = true;
} else {
// Compare the length of the received content and the 'Content-Length' header.
// If the 'Content-Length' header is absent, the length of the content is determined by the end of
// the connection, so it is perfectly fine.
prematureClosure = contentLength > 0;
}
if (!prematureClosure) {
out.add(LastHttpContent.EMPTY_LAST_CONTENT);
}
resetNow();
return;
case SKIP_CONTROL_CHARS: // fall-trough
case READ_INITIAL:// fall-trough
case BAD_MESSAGE: // fall-trough
case UPGRADED: // fall-trough
// Do nothing
break;
default:
throw new IllegalStateException("Unhandled state " + currentState);
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does decodeLast() do?
decodeLast() is a function in the netty codebase, defined in codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectDecoder.java.
Where is decodeLast() defined?
decodeLast() is defined in codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectDecoder.java at line 559.
What does decodeLast() call?
decodeLast() calls 2 function(s): isDecodingRequest, resetNow.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free