Repository navigation
Conversation
The pipeline client wrote a request body with neither Content-Length nor Transfer-Encoding. A server frames such a request with no body (RFC 9112 section 6.3), so it read the body as the start of the next request on the shared connection and answered 400. Post with a strings.Reader and Dor with a retryablehttp request both hit this: Dor passed req.Body and dropped req.ContentLength, and nothing set AutomaticContentLength. Fix it where every entry point meets, in do. A request with a body gets one Content-Length, taken from the first source that knows it: the caller's ContentLength when it is above 0 (Do and Dor), the length of a bytes.Buffer, bytes.Reader or strings.Reader, or else the body read into memory with io.ReadAll. A body read for its length is sent from that buffer, and a read error is returned before anything is queued. A caller that sets Content-Length, in any letter case, has it sent once, as given. A caller that sets Transfer-Encoding keeps its hand-chunked body as is, since a Content-Length next to it would give the message two lengths. An empty body gets no Content-Length, as before. The new call pushed do over the cyclomatic-complexity limit, so the request-path code moves out of it into requestPath, unchanged. I did not route this through AutomaticContentLength. That path only knows two body types, and the header line it writes lacks the closing CRLF. The commented-out chunked branch in clientpipeline stays as it is. A raw GET or HEAD whose body has no length now carries a Content-Length too, where the body used to run into the next request. An opaque body of unknown length is held in memory until its request is written. Fixes: #567 Signed-off-by: Dwi Siswanto <[email protected]>
Mzack9999
approved these changes
Nov 21, 2026
Mzack9999
deleted the
dwisiswant0/fix/pipelineclient/send-content-length-with-request-bodies
branch
November 21, 2026 16:46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The pipeline client wrote a request body with neither Content-Length nor
Transfer-Encoding. A server frames such a request with no body (RFC 9112
section 6.3), so it read the body as the start of the next request on
the shared connection and answered 400. Post with a strings.Reader and
Dor with a retryablehttp request both hit this: Dor passed req.Body and
dropped req.ContentLength, and nothing set AutomaticContentLength.
Fix it where every entry point meets, in do. A request with a body gets
one Content-Length, taken from the first source that knows it: the
caller's ContentLength when it is above 0 (Do and Dor), the length of a
bytes.Buffer, bytes.Reader or strings.Reader, or else the body read into
memory with io.ReadAll. A body read for its length is sent from that
buffer, and a read error is returned before anything is queued.
A caller that sets Content-Length, in any letter case, has it sent once,
as given. A caller that sets Transfer-Encoding keeps its hand-chunked
body as is, since a Content-Length next to it would give the message two
lengths. An empty body gets no Content-Length, as before.
The new call pushed do over the cyclomatic-complexity limit, so the
request-path code moves out of it into requestPath, unchanged.
I did not route this through AutomaticContentLength. That path only
knows two body types, and the header line it writes lacks the closing
CRLF. The commented-out chunked branch in clientpipeline stays as it is.
A raw GET or HEAD whose body has no length now carries a Content-Length
too, where the body used to run into the next request. An opaque body of
unknown length is held in memory until its request is written.
Fixes: #567