Home / Class/ HttpPostStandardRequestDecoderTest Class — netty Architecture

HttpPostStandardRequestDecoderTest Class — netty Architecture

Architecture documentation for the HttpPostStandardRequestDecoderTest class in HttpPostStandardRequestDecoderTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  700bdd36_e58a_9cef_6fb4_774362c57167["HttpPostStandardRequestDecoderTest"]
  d4e9cfc9_9cbd_39d7_b696_0a6c2828d861["HttpPostStandardRequestDecoderTest.java"]
  700bdd36_e58a_9cef_6fb4_774362c57167 -->|defined in| d4e9cfc9_9cbd_39d7_b696_0a6c2828d861
  381f228f_56fb_428a_f75c_ef7bd9db769d["testDecodeAttributes()"]
  700bdd36_e58a_9cef_6fb4_774362c57167 -->|method| 381f228f_56fb_428a_f75c_ef7bd9db769d
  7a56f4ef_7b98_6a9f_565a_c64dc7ac26a7["testDecodeSingleAttributeWithNoValue()"]
  700bdd36_e58a_9cef_6fb4_774362c57167 -->|method| 7a56f4ef_7b98_6a9f_565a_c64dc7ac26a7
  ce952403_f13a_514a_e165_98b5be91570a["testDecodeSingleAttributeWithNoValueEmptyLast()"]
  700bdd36_e58a_9cef_6fb4_774362c57167 -->|method| ce952403_f13a_514a_e165_98b5be91570a
  d3f2939e_4c14_7593_c5b5_b62373282c13["testDecodeEndAttributeWithNoValue()"]
  700bdd36_e58a_9cef_6fb4_774362c57167 -->|method| d3f2939e_4c14_7593_c5b5_b62373282c13
  7f6e09c9_ed38_ec51_994a_8001760a3b51["testDecodeJsonAttributeAsEmpty()"]
  700bdd36_e58a_9cef_6fb4_774362c57167 -->|method| 7f6e09c9_ed38_ec51_994a_8001760a3b51
  15264973_3d3a_e3fe_c95d_c2bb4d276138["testDecodeJsonAttributeAsEmptyAndNoHeaders()"]
  700bdd36_e58a_9cef_6fb4_774362c57167 -->|method| 15264973_3d3a_e3fe_c95d_c2bb4d276138
  d6cd8ea5_c927_fe2b_f240_bd0a11a447f8["testDecodeStartAttributeWithNoValue()"]
  700bdd36_e58a_9cef_6fb4_774362c57167 -->|method| d6cd8ea5_c927_fe2b_f240_bd0a11a447f8
  a75526f9_00ed_6a24_68ec_684b4866b46e["testDecodeMultipleAttributesWithNoValue()"]
  700bdd36_e58a_9cef_6fb4_774362c57167 -->|method| a75526f9_00ed_6a24_68ec_684b4866b46e
  06b91001_a717_fb7f_c26d_61a0c70eb2f6["testDecodeNestedAttributeWithNoValue()"]
  700bdd36_e58a_9cef_6fb4_774362c57167 -->|method| 06b91001_a717_fb7f_c26d_61a0c70eb2f6
  97b58ea0_ab81_6c76_1c96_c74cefc5b96c["testDecodeAttributesWithAmpersandPrefixSkipsNullAttribute()"]
  700bdd36_e58a_9cef_6fb4_774362c57167 -->|method| 97b58ea0_ab81_6c76_1c96_c74cefc5b96c
  7f0d1ca0_7374_eb69_4d00_2687c0cfe688["testDecodeZeroAttributesWithAmpersandPrefix()"]
  700bdd36_e58a_9cef_6fb4_774362c57167 -->|method| 7f0d1ca0_7374_eb69_4d00_2687c0cfe688
  9de7cd8e_0172_c2bb_0092_f3395d53b58e["DefaultHttpDataFactory()"]
  700bdd36_e58a_9cef_6fb4_774362c57167 -->|method| 9de7cd8e_0172_c2bb_0092_f3395d53b58e
  60cb6c7f_94bd_db1f_cddc_21c53027d383["assertMemoryAttribute()"]
  700bdd36_e58a_9cef_6fb4_774362c57167 -->|method| 60cb6c7f_94bd_db1f_cddc_21c53027d383

Relationship Graph

Source Code

codec-http/src/test/java/io/netty/handler/codec/http/multipart/HttpPostStandardRequestDecoderTest.java lines 33–231

class HttpPostStandardRequestDecoderTest {

    @Test
    void testDecodeAttributes() {
        String requestBody = "key1=value1&key2=value2";

        HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/upload");

        HttpPostStandardRequestDecoder decoder = new HttpPostStandardRequestDecoder(httpDiskDataFactory(), request);
        ByteBuf buf = Unpooled.wrappedBuffer(requestBody.getBytes(CharsetUtil.UTF_8));
        DefaultHttpContent httpContent = new DefaultLastHttpContent(buf);
        decoder.offer(httpContent);

        assertEquals(2, decoder.getBodyHttpDatas().size());
        assertMemoryAttribute(decoder.getBodyHttpData("key1"), "value1");
        assertMemoryAttribute(decoder.getBodyHttpData("key2"), "value2");
        decoder.destroy();
    }

    @Test
    void testDecodeSingleAttributeWithNoValue() {
        String requestBody = "key1";

        HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/upload",
                headersFactory().newHeaders().add("Content-Type", "application/x-www-form-urlencoded"));

        HttpPostStandardRequestDecoder decoder = new HttpPostStandardRequestDecoder(httpDiskDataFactory(), request);
        ByteBuf buf = Unpooled.wrappedBuffer(requestBody.getBytes(CharsetUtil.UTF_8));
        DefaultHttpContent httpContent = new DefaultLastHttpContent(buf);
        decoder.offer(httpContent);

        assertEquals(1, decoder.getBodyHttpDatas().size());
        assertMemoryAttribute(decoder.getBodyHttpData("key1"), "");
        decoder.destroy();
    }

    @Test
    void testDecodeSingleAttributeWithNoValueEmptyLast() {
        String requestBody = "key1";

        HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/upload",
                headersFactory().newHeaders().add("Content-Type", "application/x-www-form-urlencoded"));

        HttpPostStandardRequestDecoder decoder = new HttpPostStandardRequestDecoder(httpDiskDataFactory(), request);
        ByteBuf buf = Unpooled.wrappedBuffer(requestBody.getBytes(CharsetUtil.UTF_8));
        DefaultHttpContent httpContent = new DefaultHttpContent(buf);
        decoder.offer(httpContent);

        decoder.offer(LastHttpContent.EMPTY_LAST_CONTENT);

        assertEquals(1, decoder.getBodyHttpDatas().size());
        assertMemoryAttribute(decoder.getBodyHttpData("key1"), "");
        decoder.destroy();
    }

    @Test
    void testDecodeEndAttributeWithNoValue() {
        String requestBody = "key1=value1&key2";

        HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/upload",
                headersFactory().newHeaders().add("Content-Type", "application/x-www-form-urlencoded"));

        HttpPostStandardRequestDecoder decoder = new HttpPostStandardRequestDecoder(httpDiskDataFactory(), request);
        ByteBuf buf = Unpooled.wrappedBuffer(requestBody.getBytes(CharsetUtil.UTF_8));
        DefaultHttpContent httpContent = new DefaultLastHttpContent(buf);
        decoder.offer(httpContent);

        assertEquals(2, decoder.getBodyHttpDatas().size());
        assertMemoryAttribute(decoder.getBodyHttpData("key1"), "value1");
        assertMemoryAttribute(decoder.getBodyHttpData("key2"), "");
        decoder.destroy();
    }

    @Test
    void testDecodeJsonAttributeAsEmpty() {
        String requestBody = "{\"iAm\": \" a JSON!\"}";

        HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/upload",
                headersFactory().newHeaders().add("Content-Type", "application/json"));

        HttpPostStandardRequestDecoder decoder = new HttpPostStandardRequestDecoder(httpDiskDataFactory(), request);

Frequently Asked Questions

What is the HttpPostStandardRequestDecoderTest class?
HttpPostStandardRequestDecoderTest is a class in the netty codebase, defined in codec-http/src/test/java/io/netty/handler/codec/http/multipart/HttpPostStandardRequestDecoderTest.java.
Where is HttpPostStandardRequestDecoderTest defined?
HttpPostStandardRequestDecoderTest is defined in codec-http/src/test/java/io/netty/handler/codec/http/multipart/HttpPostStandardRequestDecoderTest.java at line 33.

Analyze Your Own Codebase

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

Try Supermodel Free