-
Notifications
You must be signed in to change notification settings - Fork 887
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Http HEAD method errors #150
Comments
Yep, it seems from your links that all |
Aah, this is interesting. It turns out that the HEAD verb only returns the response headers, not body. This is most likely why we get an error, because we expect a body in the response. I'll fix this! |
Seems like the error is |
Using HEAD on https://www.google.com is not throwing an error. Maybe this is instead a problem with httpstatus.xyz? It seems like it's passing a content size header different from the actual response size. |
Odd, it appears the issue was indeed the content length header. It appears that Cloudflare Workers will set the content length even if no content returned as is the case with a HEAD request, not the expected behaviour at all. This is resolved from my perspective. Thank you for identifying this, I will raise a ticket with Cloudflare. |
@AnandChowdhary Just circling back to this. As I went to submit a ticket to CF it appears that the behaviour of sending content related headers is allowed by the RFC.
While I have fixed my use case, there may be potential future edge-cases where this could be an issue. |
I'd say it's best to stick to the expected If you feel strongly about this, perhaps we can open an issue or discuss this with the folks over at https://github.com/curl/curl and see if they'd want to catch this by default. |
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 Note that the HTTP method HEAD should return exactly the same headers of a GET request, this is the real purpose of the HEAD method, know the headers without receive the body. |
I want to use upptime to check if large files are online without actually downloading them. To this I have to use the HEAD HTTP method. However this is not possible due to this bug, as I get However it is intended that HEAD actually sets the Content-Length, f.e. MDN: https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD
|
Ok so apparently this has something to do with how the HTTP method is set. Currently, it is set via the CUSTOMREQUEST option, which however should not be used for methods like GET, POST, HEAD etc. but rather for really custom requests (https://curl.se/libcurl/c/CURLOPT_CUSTOMREQUEST.html). Unfortunately this is not clearly worded in the docs for libcurl, but in the curl manpages (https://curl.se/docs/manpage.html#-X) it says:
From libcurl doc:
Thus for HEAD this option should be set to true https://curl.se/libcurl/c/CURLOPT_NOBODY.html in order for curl to perform a HEAD request. |
Thank you for such a great project!
Describe the bug
Using a http HEAD method with an expected status code always returns a down result, with no status code returned in the issue. It appears that this relates to the implementation of curl as the head method is different to most others in not returning a body.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Site should be classified as up if the site returns the expected status code.
Additional context
Example Config: https://github.com/SamPetherbridge/status.httpstatus.xyz/blob/master/.upptimerc.yml#L37
Example issue: #SamPetherbridge/status.statuscodes.peth.me#2
The text was updated successfully, but these errors were encountered: