Don't read body in HEAD requests#63
Merged
andyburke merged 2 commits intoandyburke:masterandyburke/UnityHTTP:masterfrom Jul 7, 2016
Merged
Don't read body in HEAD requests#63andyburke merged 2 commits intoandyburke:masterandyburke/UnityHTTP:masterfrom
andyburke merged 2 commits intoandyburke:masterandyburke/UnityHTTP:masterfrom
Conversation
Owner
|
How does the exception get thrown? My understanding was that with no content-length header, this would essentially do nothing, so HEAD requests would work. Does the HEAD request have a content-length header but no content? I'm open to merging something like this, but I would like to understand more about what's happening. |
Contributor
Author
|
Yes, a head response is exactly like a get response but without a body. The Example use case is getting the size of a file without downloading it, or checking the last modified date of a file. |
Owner
|
LGTM |
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 Response class tries to read the body and compare the content length of the body with the content length in the header.
There is no body in HEAD requests so of course the body length and header value don't match, which throws an exception.
This PR skips reading the response body if the request method is
head.