Closed andzdroid closed 8 years ago
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.
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.
LGTM
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
.