testDelimiterExceedLeftSpaceInCurrentBuffer() — netty Function Reference
Architecture documentation for the testDelimiterExceedLeftSpaceInCurrentBuffer() function in HttpPostMultiPartRequestDecoderTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 3ed462e6_092a_55ad_9390_85dfe7b115a7["testDelimiterExceedLeftSpaceInCurrentBuffer()"] 8ca6727e_4177_9097_12de_7bccb17e5dea["HttpPostMultiPartRequestDecoderTest"] 3ed462e6_092a_55ad_9390_85dfe7b115a7 -->|defined in| 8ca6727e_4177_9097_12de_7bccb17e5dea style 3ed462e6_092a_55ad_9390_85dfe7b115a7 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
codec-http/src/test/java/io/netty/handler/codec/http/multipart/HttpPostMultiPartRequestDecoderTest.java lines 98–156
@Test
public void testDelimiterExceedLeftSpaceInCurrentBuffer() {
String delimiter = "--861fbeab-cd20-470c-9609-d40a0f704466";
String suffix = '\n' + delimiter + "--\n";
byte[] bsuffix = suffix.getBytes(CharsetUtil.UTF_8);
int partOfDelimiter = bsuffix.length / 2;
int bytesLastChunk = 355 - partOfDelimiter; // to try to have an out of bound since content is > delimiter
byte[] bsuffix1 = Arrays.copyOf(bsuffix, partOfDelimiter);
byte[] bsuffix2 = Arrays.copyOfRange(bsuffix, partOfDelimiter, bsuffix.length);
String prefix = delimiter + "\n" +
"Content-Disposition: form-data; name=\"image\"; filename=\"guangzhou.jpeg\"\n" +
"Content-Type: image/jpeg\n" +
"Content-Length: " + bytesLastChunk + "\n\n";
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() + bytesLastChunk + suffix.length());
// Factory using Memory mode
HttpDataFactory factory = new DefaultHttpDataFactory(false);
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());
httpContent.release();
// Chunk less than Delimiter size but containing part of delimiter
byte[] body = new byte[bytesLastChunk + bsuffix1.length];
Arrays.fill(body, (byte) 2);
for (int i = 0; i < bsuffix1.length; i++) {
body[bytesLastChunk + i] = bsuffix1[i];
}
ByteBuf content = Unpooled.wrappedBuffer(body);
httpContent = new DefaultHttpContent(content);
decoder.offer(httpContent); // Ouf of range before here
assertNotNull(((HttpData) decoder.currentPartialHttpData()).content());
httpContent.release();
content = Unpooled.wrappedBuffer(bsuffix2);
httpContent = new DefaultHttpContent(content);
decoder.offer(httpContent);
assertNull((HttpData) decoder.currentPartialHttpData());
httpContent.release();
decoder.offer(new DefaultLastHttpContent());
FileUpload data = (FileUpload) decoder.getBodyHttpDatas().get(0);
assertEquals(data.length(), bytesLastChunk);
assertEquals(true, data.isInMemory());
InterfaceHttpData[] httpDatas = decoder.getBodyHttpDatas().toArray(new InterfaceHttpData[0]);
for (InterfaceHttpData httpData : httpDatas) {
assertEquals(1, httpData.refCnt(), "Before cleanAllHttpData should be 1");
}
factory.cleanAllHttpData();
for (InterfaceHttpData httpData : httpDatas) {
assertEquals(1, httpData.refCnt(), "After cleanAllHttpData should be 1 if in Memory");
}
decoder.destroy();
for (InterfaceHttpData httpData : httpDatas) {
assertEquals(0, httpData.refCnt(), "RefCnt should be 0");
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does testDelimiterExceedLeftSpaceInCurrentBuffer() do?
testDelimiterExceedLeftSpaceInCurrentBuffer() is a function in the netty codebase, defined in codec-http/src/test/java/io/netty/handler/codec/http/multipart/HttpPostMultiPartRequestDecoderTest.java.
Where is testDelimiterExceedLeftSpaceInCurrentBuffer() defined?
testDelimiterExceedLeftSpaceInCurrentBuffer() is defined in codec-http/src/test/java/io/netty/handler/codec/http/multipart/HttpPostMultiPartRequestDecoderTest.java at line 98.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free