You haven't shown us any code ...
...but sounds like you're trying to read an HTTP "response" from a HEAD request (instead of only accessing the HTTP response headers).
Per the RFC:
https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.4
The HEAD method is identical to GET except that the server MUST NOT
return a message-body in the response. The metainformation contained
in the HTTP headers in response to a HEAD request SHOULD be identical
to the information sent in response to a GET request. This method can
be used for obtaining metainformation about the entity implied by the
request without transferring the entity-body itself. This method is
often used for testing hypertext links for validity, accessibility,
and recent modification.
In other words, the response to a HEAD request doesn't have a body. If you try to read one, you'll get an EOF. I suspect that's what's happening here.
Thank you for updating your question with this code. It looks like you're using Go.
Try this:
res, err := http.Head("https://golang.org")
if err != nil {
panic(err)
}
println(res.StatusCode)
And remember: res will have no Body.
ADDENDUM
– Rajesh Sethi
I did try with Postman, it didn't respond with HEADER information.
I tried Curl, it says "Empty reply from server".
The code above, resp, err := http.Head("speed.hetzner.de/100MB.bin")
, throws the same "EOF" error.
– paulsm4
Cool - thank you. So it sounds like your original surmise is correct:
Your code is OK: you're not "doing anything wrong" (like trying to read a "Body" that isn't there).
Rather, that particular URL
(speed.hetzner.de) is blocking (or at least refusing to process) HEAD requests.