http响应在docker中被截断了

时间:2015-12-28 10:51:42

标签: docker netty

我使用netty构建了一个http服务器。当它在我的mac中运行时一切都很好,但是当我在docker镜像中运行它时,http响应总是在大于460k时被截断。

问题是什么?请帮忙。

1 个答案:

答案 0 :(得分:0)

您是否使用聚合器聚合http响应?看一下HttpObjectDecoder的源代码。无论http消息本身是否为传输编码,它都会产生更大的http响应。

默认的maxChunk大小是8k。甚至可读的字节就足够了,它会将其分块。请参阅以下代码:

`case READ_FIXED_LENGTH_CONTENT:{             int readLimit = actualReadableBytes();

        // Check if the buffer is readable first as we use the readable byte count
        // to create the HttpChunk. This is needed as otherwise we may end up with
        // create a HttpChunk instance that contains an empty buffer and so is
        // handled like it is the last HttpChunk.
        //
        // See https://github.com/netty/netty/issues/433
        if (readLimit == 0) {
            return;
        }

        int toRead = Math.min(readLimit, maxChunkSize);
        if (toRead > chunkSize) {
            toRead = (int) chunkSize;
        }
        ByteBuf content = readBytes(ctx.alloc(), buffer, toRead);
        chunkSize -= toRead;

`