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

fix: redirect on 308 (Permanent Redirect) too #876

Merged
merged 2 commits into from Nov 14, 2019
Merged

fix: redirect on 308 (Permanent Redirect) too #876

merged 2 commits into from Nov 14, 2019

Conversation

chanseokoh
Copy link
Contributor

Fixes #873.

@chanseokoh chanseokoh requested a review from a team as a code owner November 4, 2019 18:23
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Nov 4, 2019

public void testIsRedirect_3xx() {
assertTrue(HttpStatusCodes.isRedirect(301));
assertTrue(HttpStatusCodes.isRedirect(302));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about 309 to 399? These are all undefined redirect codes according to HTTP.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the method name should really be isDefinedRedirect or such, given where this code is used to handle automatic redirection. The Javadoc at least describes the behavior correctly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The behavior for other 3xx codes is not defined in docs or tests. I suspect the current behavior in this case never got much thought.

Think of it this way: if we do see a 315 code what should we do with it? The answer is treat it as a redirect.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't disagree. The library could be modified to redirect on all 3xx, but I don't feel like I will introduce that kind of behavior change myself right now. That sounds like we need more discussions, and I don't feel confident to introduce such a change, as I don't think I have enough expertise on this matter. For now, I will just allow redirecting 308 that at least should have been covered here. Nothing more, just one change that I believe should be fixed at least.

@chanseokoh chanseokoh changed the title Redirect on 308 (Permanent Redirect) too fix: redirect on 308 (Permanent Redirect) too Nov 11, 2019
@chanseokoh chanseokoh added the kokoro:run Add this label to force Kokoro to re-run the tests. label Nov 11, 2019
@kokoro-team kokoro-team removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Nov 11, 2019
@elharo elharo merged commit 501ede8 into googleapis:master Nov 14, 2019
@chanseokoh chanseokoh deleted the i873-redirect-308 branch November 14, 2019 19:13
clundin25 pushed a commit to clundin25/google-http-java-client that referenced this pull request Aug 11, 2022
🤖 I have created a release *beep* *boop*
---


### Updating meta-information for bleeding-edge SNAPSHOT release.

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

setFollowRedirects(true) does not follow 308 (Permanent Redirect)
4 participants