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

Redirect behavior should match the HTTP specification #12

Closed
masumsoft opened this issue Jan 20, 2014 · 4 comments
Closed

Redirect behavior should match the HTTP specification #12

masumsoft opened this issue Jan 20, 2014 · 4 comments
Labels
Milestone

Comments

@masumsoft
Copy link

As far as I know, not all of the 300-399 http response codes needs to have a redirect. But looking at the code, I found you are redirecting everything in 300-399. Please look at the following url to have a reference:

http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

@jamestalmage
Copy link
Contributor

We are redirecting when the response

  1. has a status code of 300-309
    and
  2. has a location header.

From your link:

If the server has a preferred choice of representation, it SHOULD include the specific URI for that representation in the Location field; user agents MAY use the Location field value for automatic redirection

What we are not taking into account is that we should probably only be redirecting for GET and HEAD methods.

If the [301 | 302 | 307] status code is received in response to a request other than GET or HEAD, the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user, since this might change the conditions under which the request was issued.

When correcting this, it's probably advisable to include the addition of a alwaysFollow flag that will ignore the above spec and continue operating as before. (perhaps the alwaysFollow flag should initially default to true for backwards compatibility).

@jamestalmage jamestalmage changed the title Not all 300+ http codes mean to redirect Mimic Browser Behavior Jul 4, 2015
@jamestalmage jamestalmage changed the title Mimic Browser Behavior Mimic Browser Behavior when deciding to follow redirects. Jul 4, 2015
jamestalmage added a commit that referenced this issue Jul 4, 2015
Allow users to intercept and perform influence the redirection
themselves. This adds a `makeRequest` option that can be used to
do just that. For now, my plan is to leave it undocumented,
because I want to get a release out, and don't want to commit
to this API decision just yet. Specifically, I want make some
progress on #19, and #12 before committing to exactly how
it will behave.
@jamestalmage
Copy link
Contributor

This is going to be addressed eventually. See #19.

@jamestalmage jamestalmage added this to the 1.0.0 milestone Sep 10, 2015
@jamestalmage
Copy link
Contributor

I've started the creation of a test suite that logs the redirect behavior across browsers.

See: https://github.com/jamestalmage/browser-redirect-test

This was referenced Sep 15, 2015
@RubenVerborgh RubenVerborgh changed the title Mimic Browser Behavior when deciding to follow redirects. Redirect behavior should match the HTTP specification Oct 20, 2016
@RubenVerborgh
Copy link
Collaborator

Rather than following what browsers happen to do, let's stick to the HTTP specification, which is what browsers and servers should follow anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants