loadDataMultipartOptimized() — netty Function Reference
Architecture documentation for the loadDataMultipartOptimized() function in HttpPostMultipartRequestDecoder.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD dc1f20fd_3e63_28d8_bb25_33d293baeee4["loadDataMultipartOptimized()"] d07408ef_0ab6_54bb_c64e_0b5b9a0aac25["HttpPostMultipartRequestDecoder"] dc1f20fd_3e63_28d8_bb25_33d293baeee4 -->|defined in| d07408ef_0ab6_54bb_c64e_0b5b9a0aac25 44dc9a0e_9473_e766_e499_985b3abd1cad["InterfaceHttpData()"] 44dc9a0e_9473_e766_e499_985b3abd1cad -->|calls| dc1f20fd_3e63_28d8_bb25_33d293baeee4 797f71de_514d_ed61_72d4_a77fc4bdb93f["rewriteCurrentBuffer()"] dc1f20fd_3e63_28d8_bb25_33d293baeee4 -->|calls| 797f71de_514d_ed61_72d4_a77fc4bdb93f style dc1f20fd_3e63_28d8_bb25_33d293baeee4 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostMultipartRequestDecoder.java lines 1195–1260
private static boolean loadDataMultipartOptimized(ByteBuf undecodedChunk, String delimiter, HttpData httpData) {
if (!undecodedChunk.isReadable()) {
return false;
}
final int startReaderIndex = undecodedChunk.readerIndex();
final byte[] bdelimiter = delimiter.getBytes(httpData.getCharset());
int posDelimiter = HttpPostBodyUtil.findDelimiter(undecodedChunk, startReaderIndex, bdelimiter, true);
if (posDelimiter < 0) {
// Not found but however perhaps because incomplete so search LF or CRLF from the end.
// Possible last bytes contain partially delimiter
// (delimiter is possibly partially there, at least 1 missing byte),
// therefore searching last delimiter.length +1 (+1 for CRLF instead of LF)
int readableBytes = undecodedChunk.readableBytes();
int lastPosition = readableBytes - bdelimiter.length - 1;
if (lastPosition < 0) {
// Not enough bytes, but at most delimiter.length bytes available so can still try to find CRLF there
lastPosition = 0;
}
posDelimiter = HttpPostBodyUtil.findLastLineBreak(undecodedChunk, startReaderIndex + lastPosition);
// No LineBreak, however CR can be at the end of the buffer, LF not yet there (issue #11668)
// Check if last CR (if any) shall not be in the content (definedLength vs actual length + buffer - 1)
if (posDelimiter < 0 &&
httpData.definedLength() == httpData.length() + readableBytes - 1 &&
undecodedChunk.getByte(readableBytes + startReaderIndex - 1) == HttpConstants.CR) {
// Last CR shall precede a future LF
lastPosition = 0;
posDelimiter = readableBytes - 1;
}
if (posDelimiter < 0) {
// not found so this chunk can be fully added
ByteBuf content = undecodedChunk.copy();
try {
httpData.addContent(content, false);
} catch (IOException e) {
throw new ErrorDataDecoderException(e);
}
undecodedChunk.readerIndex(startReaderIndex);
undecodedChunk.writerIndex(startReaderIndex);
return false;
}
// posDelimiter is not from startReaderIndex but from startReaderIndex + lastPosition
posDelimiter += lastPosition;
if (posDelimiter == 0) {
// Nothing to add
return false;
}
// Not fully but still some bytes to provide: httpData is not yet finished since delimiter not found
ByteBuf content = undecodedChunk.copy(startReaderIndex, posDelimiter);
try {
httpData.addContent(content, false);
} catch (IOException e) {
throw new ErrorDataDecoderException(e);
}
rewriteCurrentBuffer(undecodedChunk, posDelimiter);
return false;
}
// Delimiter found at posDelimiter, including LF or CRLF, so httpData has its last chunk
ByteBuf content = undecodedChunk.copy(startReaderIndex, posDelimiter);
try {
httpData.addContent(content, true);
} catch (IOException e) {
throw new ErrorDataDecoderException(e);
}
rewriteCurrentBuffer(undecodedChunk, posDelimiter);
return true;
}
Domain
Subdomains
Defined In
Calls
Called By
Source
Frequently Asked Questions
What does loadDataMultipartOptimized() do?
loadDataMultipartOptimized() is a function in the netty codebase, defined in codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostMultipartRequestDecoder.java.
Where is loadDataMultipartOptimized() defined?
loadDataMultipartOptimized() is defined in codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostMultipartRequestDecoder.java at line 1195.
What does loadDataMultipartOptimized() call?
loadDataMultipartOptimized() calls 1 function(s): rewriteCurrentBuffer.
What calls loadDataMultipartOptimized()?
loadDataMultipartOptimized() is called by 1 function(s): InterfaceHttpData.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free