Skip to content
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

net/http: Add failsafe on status code 301 but response behaves as 200 status code #50579

Closed
ronysandoval opened this issue Jan 12, 2022 · 3 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@ronysandoval
Copy link

What is the URL of the page with the issue?

https://httpbun.com/status/301

What is your user agent?

Mozilla/5.0 (X11; Linux x86_64; rv:95.0) Gecko/20100101 Firefox/95.0

Screenshot

image
image

What did you do?

When you are doing a normal fetch and the response is 301 status code, there should be a fail-safe because some sites are throwing this but returning content and behaves like 200 response, this request keeps failing because they don't send Location header as a normal 301 response should do, the page also have content-type and content-length so maybe be validated by that headers.
This response works when doing curl or visiting from normal browser.

What did you expect to see?

I expect to see the response like a normal fetch when page contains content-length and content-type but no Location header.

What did you see instead?

I get an error message that says the following:
'301 response missing Location header'

@davecheney
Copy link
Contributor

Thank you for raising this issue. You mentioned that Is is related to the net/http package, but your issue report contains no go code. Would it be possible for you to provide a short, stand alone, runnable program that demonstrates the issue you are experiencing. Thank you.

@davecheney davecheney added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. and removed pkgsite labels Jan 12, 2022
@ronysandoval
Copy link
Author

You can get the code example from here: https://rafallorenz.com/go/customize-http-client/
but basically when the request is executed and this function is called
*http.Client.Do(req) is where should go to do the normal fetch
having this on the library
func (c *Client) Do(req *Request) (*Response, error) {
return c.do(req)
}
and that library is currently at /usr/lib/go/src/net/http/client.go

@seankhliao
Copy link
Member

Duplicate of #49281

@seankhliao seankhliao marked this as a duplicate of #49281 Jan 12, 2022
@golang golang locked and limited conversation to collaborators Jan 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants