commonTestBigFileDelimiterInMiddleChunk() — netty Function Reference
Architecture documentation for the commonTestBigFileDelimiterInMiddleChunk() function in HttpPostMultiPartRequestDecoderTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 7eb4c671_cbbe_57a8_2f8d_0880061c4803["commonTestBigFileDelimiterInMiddleChunk()"] 8ca6727e_4177_9097_12de_7bccb17e5dea["HttpPostMultiPartRequestDecoderTest"] 7eb4c671_cbbe_57a8_2f8d_0880061c4803 -->|defined in| 8ca6727e_4177_9097_12de_7bccb17e5dea 7231f1f8_4457_2733_e62f_b1333e9aff80["testBIgFileUploadDelimiterInMiddleChunkDecoderDiskFactory()"] 7231f1f8_4457_2733_e62f_b1333e9aff80 -->|calls| 7eb4c671_cbbe_57a8_2f8d_0880061c4803 b7cbf6e2_a870_bcbe_c097_720ab9764ad4["testBIgFileUploadDelimiterInMiddleChunkDecoderMemoryFactory()"] b7cbf6e2_a870_bcbe_c097_720ab9764ad4 -->|calls| 7eb4c671_cbbe_57a8_2f8d_0880061c4803 cdeb0206_1693_c03f_b392_2e5b08947c84["testBIgFileUploadDelimiterInMiddleChunkDecoderMixedFactory()"] cdeb0206_1693_c03f_b392_2e5b08947c84 -->|calls| 7eb4c671_cbbe_57a8_2f8d_0880061c4803 style 7eb4c671_cbbe_57a8_2f8d_0880061c4803 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
codec-http/src/test/java/io/netty/handler/codec/http/multipart/HttpPostMultiPartRequestDecoderTest.java lines 158–258
private void commonTestBigFileDelimiterInMiddleChunk(HttpDataFactory factory, boolean inMemory)
throws IOException {
int nbChunks = 100;
int bytesPerChunk = 100000;
int bytesLastChunk = 10000;
int fileSize = bytesPerChunk * nbChunks + bytesLastChunk; // set Xmx to a number lower than this and it crashes
String delimiter = "--861fbeab-cd20-470c-9609-d40a0f704466";
String prefix = delimiter + "\n" +
"Content-Disposition: form-data; name=\"image\"; filename=\"guangzhou.jpeg\"\n" +
"Content-Type: image/jpeg\n" +
"Content-Length: " + fileSize + "\n" +
"\n";
String suffix1 = "\n" +
"--861fbeab-";
String suffix2 = "cd20-470c-9609-d40a0f704466--\n";
String suffix = suffix1 + suffix2;
HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/upload");
request.headers().set("content-type", "multipart/form-data; boundary=861fbeab-cd20-470c-9609-d40a0f704466");
request.headers().set("content-length", prefix.length() + fileSize + suffix.length());
HttpPostMultipartRequestDecoder decoder = new HttpPostMultipartRequestDecoder(factory, request);
ByteBuf buf = Unpooled.wrappedBuffer(prefix.getBytes(CharsetUtil.UTF_8));
DefaultHttpContent httpContent = new DefaultHttpContent(buf);
decoder.offer(httpContent);
assertNotNull(((HttpData) decoder.currentPartialHttpData()).content());
httpContent.release();
byte[] body = new byte[bytesPerChunk];
Arrays.fill(body, (byte) 1);
// Set first bytes as CRLF to ensure it is correctly getting the last CRLF
body[0] = HttpConstants.CR;
body[1] = HttpConstants.LF;
for (int i = 0; i < nbChunks; i++) {
ByteBuf content = Unpooled.wrappedBuffer(body, 0, bytesPerChunk);
httpContent = new DefaultHttpContent(content);
decoder.offer(httpContent); // **OutOfMemory previously here**
assertNotNull(((HttpData) decoder.currentPartialHttpData()).content());
httpContent.release();
}
byte[] bsuffix1 = suffix1.getBytes(CharsetUtil.UTF_8);
byte[] previousLastbody = new byte[bytesLastChunk - bsuffix1.length];
byte[] bdelimiter = delimiter.getBytes(CharsetUtil.UTF_8);
byte[] lastbody = new byte[2 * bsuffix1.length];
Arrays.fill(previousLastbody, (byte) 1);
previousLastbody[0] = HttpConstants.CR;
previousLastbody[1] = HttpConstants.LF;
Arrays.fill(lastbody, (byte) 1);
// put somewhere a not valid delimiter
for (int i = 0; i < bdelimiter.length; i++) {
previousLastbody[i + 10] = bdelimiter[i];
}
lastbody[0] = HttpConstants.CR;
lastbody[1] = HttpConstants.LF;
for (int i = 0; i < bsuffix1.length; i++) {
lastbody[bsuffix1.length + i] = bsuffix1[i];
}
ByteBuf content2 = Unpooled.wrappedBuffer(previousLastbody, 0, previousLastbody.length);
httpContent = new DefaultHttpContent(content2);
decoder.offer(httpContent);
assertNotNull(((HttpData) decoder.currentPartialHttpData()).content());
httpContent.release();
content2 = Unpooled.wrappedBuffer(lastbody, 0, lastbody.length);
httpContent = new DefaultHttpContent(content2);
decoder.offer(httpContent);
assertNotNull(((HttpData) decoder.currentPartialHttpData()).content());
httpContent.release();
content2 = Unpooled.wrappedBuffer(suffix2.getBytes(CharsetUtil.UTF_8));
httpContent = new DefaultHttpContent(content2);
decoder.offer(httpContent);
assertNull(decoder.currentPartialHttpData());
httpContent.release();
decoder.offer(new DefaultLastHttpContent());
FileUpload data = (FileUpload) decoder.getBodyHttpDatas().get(0);
assertEquals(data.length(), fileSize);
assertEquals(inMemory, data.isInMemory());
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does commonTestBigFileDelimiterInMiddleChunk() do?
commonTestBigFileDelimiterInMiddleChunk() is a function in the netty codebase, defined in codec-http/src/test/java/io/netty/handler/codec/http/multipart/HttpPostMultiPartRequestDecoderTest.java.
Where is commonTestBigFileDelimiterInMiddleChunk() defined?
commonTestBigFileDelimiterInMiddleChunk() is defined in codec-http/src/test/java/io/netty/handler/codec/http/multipart/HttpPostMultiPartRequestDecoderTest.java at line 158.
What calls commonTestBigFileDelimiterInMiddleChunk()?
commonTestBigFileDelimiterInMiddleChunk() is called by 3 function(s): testBIgFileUploadDelimiterInMiddleChunkDecoderDiskFactory, testBIgFileUploadDelimiterInMiddleChunkDecoderMemoryFactory, testBIgFileUploadDelimiterInMiddleChunkDecoderMixedFactory.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free