Home / Function/ testMultipartCodecWithCRasEndOfAttribute() — netty Function Reference

testMultipartCodecWithCRasEndOfAttribute() — netty Function Reference

Architecture documentation for the testMultipartCodecWithCRasEndOfAttribute() function in HttpPostRequestDecoderTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  015c1b58_a0a6_08a3_b1cb_0667ce054c53["testMultipartCodecWithCRasEndOfAttribute()"]
  d3dadcbe_07b1_86dc_3f34_5a56e9d1367e["HttpPostRequestDecoderTest"]
  015c1b58_a0a6_08a3_b1cb_0667ce054c53 -->|defined in| d3dadcbe_07b1_86dc_3f34_5a56e9d1367e
  style 015c1b58_a0a6_08a3_b1cb_0667ce054c53 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http/src/test/java/io/netty/handler/codec/http/multipart/HttpPostRequestDecoderTest.java lines 150–195

    @Test
    public void testMultipartCodecWithCRasEndOfAttribute() throws Exception {
        final String boundary = "dLV9Wyq26L_-JQxk6ferf-RT153LhOO";

        // Force to use memory-based data.
        final DefaultHttpDataFactory inMemoryFactory = new DefaultHttpDataFactory(false);
        // Build test case
        String extradata = "aaaa";
        String[] datas = new String[5];
        for (int i = 0; i < 4; i++) {
            datas[i] = extradata;
            for (int j = 0; j < i; j++) {
                datas[i] += '\r';
            }
        }

        for (int i = 0; i < 4; i++) {
            final DefaultFullHttpRequest req = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST,
                    "http://localhost");
            req.setDecoderResult(DecoderResult.SUCCESS);
            req.headers().add(HttpHeaderNames.CONTENT_TYPE, "multipart/form-data; boundary=" + boundary);
            req.headers().add(HttpHeaderNames.TRANSFER_ENCODING, HttpHeaderValues.CHUNKED);
            final String body =
                    "--" + boundary + "\r\n" +
                            "Content-Disposition: form-data; name=\"file" + i + "\"\r\n" +
                            "Content-Type: image/gif\r\n" +
                            "\r\n" +
                            datas[i] + "\r\n" +
                            "--" + boundary + "--\r\n";

            req.content().writeBytes(body.getBytes(CharsetUtil.UTF_8));
            // Create decoder instance to test.
            final HttpPostRequestDecoder decoder = new HttpPostRequestDecoder(inMemoryFactory, req);
            assertFalse(decoder.getBodyHttpDatas().isEmpty());
            // Check correctness: data size
            InterfaceHttpData httpdata = decoder.getBodyHttpData("file" + i);
            assertNotNull(httpdata);
            Attribute attribute = (Attribute) httpdata;
            byte[] datar = attribute.get();
            assertNotNull(datar);
            assertEquals(datas[i].getBytes(CharsetUtil.UTF_8).length, datar.length);

            decoder.destroy();
            assertTrue(req.release());
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does testMultipartCodecWithCRasEndOfAttribute() do?
testMultipartCodecWithCRasEndOfAttribute() is a function in the netty codebase, defined in codec-http/src/test/java/io/netty/handler/codec/http/multipart/HttpPostRequestDecoderTest.java.
Where is testMultipartCodecWithCRasEndOfAttribute() defined?
testMultipartCodecWithCRasEndOfAttribute() is defined in codec-http/src/test/java/io/netty/handler/codec/http/multipart/HttpPostRequestDecoderTest.java at line 150.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free