Describe the bug
In HttpClientFactory.doEncodeHttp1Body, a chunked HTTP/1.1 request body is framed per data frame, with the chunk size line written when the FIN flag is set and the trailing CRLF written when the INIT flag is set:
if (exchange.requestChunked && flags != NONE)
{
int chunkLimit = 0;
if (hasFin(flags))
{
// chunk size and CRLF
}
// payload
if (hasInit(flags))
{
// trailing CRLF
}
}
For a message carried in a single frame (both INIT and FIN set) the result is a correct chunk: size line, payload, CRLF. For a message that spans several frames the first frame (INIT only) is written as payload followed by CRLF with no size line, and the last frame (FIN only) is written as a size line and payload with no trailing CRLF. The size line also describes only the last fragment rather than the whole message.
To Reproduce
Found by reading the code, not reproduced. A reproduction would be a chunked request whose body message is delivered to the client binding in more than one data frame, then inspecting the bytes written to the network.
Expected behavior
Each chunk is framed once: the size line before the first fragment's payload and the trailing CRLF after the last fragment's payload, or equivalently one chunk per frame with its own size.
Additional context
Noticed while replacing the per-module flag constants with a shared helper. The literal tests (flags & 0x01 before the size line, flags & 0x02 before the trailing CRLF) are unchanged in behavior by that change, which is why this is filed separately.
Describe the bug
In
HttpClientFactory.doEncodeHttp1Body, a chunked HTTP/1.1 request body is framed per data frame, with the chunk size line written when the FIN flag is set and the trailing CRLF written when the INIT flag is set:For a message carried in a single frame (both INIT and FIN set) the result is a correct chunk: size line, payload, CRLF. For a message that spans several frames the first frame (INIT only) is written as payload followed by CRLF with no size line, and the last frame (FIN only) is written as a size line and payload with no trailing CRLF. The size line also describes only the last fragment rather than the whole message.
To Reproduce
Found by reading the code, not reproduced. A reproduction would be a chunked request whose body message is delivered to the client binding in more than one data frame, then inspecting the bytes written to the network.
Expected behavior
Each chunk is framed once: the size line before the first fragment's payload and the trailing CRLF after the last fragment's payload, or equivalently one chunk per frame with its own size.
Additional context
Noticed while replacing the per-module flag constants with a shared helper. The literal tests (
flags & 0x01before the size line,flags & 0x02before the trailing CRLF) are unchanged in behavior by that change, which is why this is filed separately.