Allow missing HEAD content length#69
Open
GrahamCampbell wants to merge 1 commit into
Open
Conversation
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.
What's in this PR?
This relaxes the request assertion for HEAD requests so a client may omit
Content-Lengthwhen the server did not receive one. The assertion still checksContent-Lengthwhen a client sends it, and keeps the existing TRACE behavior.Why?
The test suite currently makes
Content-Lengthmandatory for HEAD requests because the default request headers includeContent-Length: 0, and bodied test cases replace it with the body length. That is too strict for clients and transports that intentionally suppress HEAD request content.If such a client kept a positive
Content-Lengthwhile sending no body, the wire message would declare bytes that never arrive, which can make servers wait for the missing request body or corrupt connection framing. A missingContent-Lengthis valid for a HEAD request with no transmitted content, and this change only tolerates that absence; it still validates the header value when a client sends one.Guzzle needs this while fixing guzzle/guzzle#3728 because its cURL handler must use cURL's no-body mode for HEAD requests to avoid waiting for response bodies that valid HEAD responses do not send. That mode suppresses request uploads, so Guzzle also has to omit positive request
Content-Lengthvalues rather than send misleading framing headers.Checklist