Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Don't read body in HEAD requests#63

Merged
andyburke merged 2 commits intoandyburke:masterandyburke/UnityHTTP:masterfrom
andzdroid:masterandzdroid/UnityHTTP:masterCopy head branch name to clipboard
Jul 7, 2016
Merged

Don't read body in HEAD requests#63
andyburke merged 2 commits intoandyburke:masterandyburke/UnityHTTP:masterfrom
andzdroid:masterandzdroid/UnityHTTP:masterCopy head branch name to clipboard

Conversation

@andzdroid
Copy link
Contributor

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.

@andyburke
Copy link
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.

@andzdroid
Copy link
Contributor Author

andzdroid commented Jul 6, 2016

Yes, a head response is exactly like a get response but without a body. The
headers are the same, including content length.

Example use case is getting the size of a file without downloading it, or checking the last modified date of a file.

@andyburke andyburke merged commit 0b9fffb into andyburke:master Jul 7, 2016
@andyburke
Copy link
Owner

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.