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
Perform HEAD request before GET #25
Comments
Sure, makes sense. PR welcome. |
Keep in mind that not all HTTP servers will support HEAD requests. If you want to speed up things, I suggest switching to core |
That's a good point! HEAD and GET will be launched on parallel and the response will be the first request to be resolved. Because got is using http/https internally, we can avoid parsing body as you suggest 🙂 |
That seems pretty wasteful of resources to me, not sure I like it.
Doesn't got always parse the body unconditionally? |
I understand your point and I did tests based on this premise. Sometimes HEAD response is fastest than GET. In the case HEAD is not supported, it doesn't be done. Need to test it again disabling parse body response.
|
We don't actually need to follow redirects in all cases. Part of the purpose of the So in summary:
Also keep in mind that |
I noted Could this change in the codebase make an improvement as you suggest? #25 (comment)? btw, this library needs to upgrade got dependency |
I noted the library is doing a GET request to determinate if the url is reachable:
https://github.com/sindresorhus/is-reachable/blob/master/index.js#L16
Normally you can use HEAD request for doing that, but some sites disable perform this request over his sites.
I found this user case in the past and my solution was to try to perform a HEAD request first, fallback into GET if is not possible:
https://github.com/urlint/url-code-status/blob/master/index.js#L16
Because HEAD is lightweight GET, make sense if you want to accept a PR improving that?
The text was updated successfully, but these errors were encountered: