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
Fixes the do not follow redirects bug #944
Fixes the do not follow redirects bug #944
Conversation
While it's easy to create a bug a figured I could also attempt to fix it. Here's my attempt, hopefully it can be useful! |
Should I be worried of having a broken build? |
Java 8 often fails. Flaky tests suck! |
@@ -370,6 +371,14 @@ public boolean getFollowSslRedirects() { | |||
return followSslRedirects; | |||
} | |||
|
|||
public void setFollowRedirects(boolean followRedirects) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you copy the Javadoc from the above setter and modify it to describe this behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course, not a problem. It's done!
Nice tests. |
The HttpEngine would not obey the set state because there was no correlation between the HttpURLConnection.setInstanceFollowRedirects method and the OkHttpClient. Fixed the missing link by adding a new setFollowRedirects method to the OkHttpClient class. Bridged the gap for the HttpURLConnection.setInstanceFollowRedirects by forwarding that state into the OkHttpClient. Now the HttpEngine will always obey the OkHttpClient redirect state when attempting the followUp phase. Added necessary test to both OkUrlFactoryTest and CallTest. square#943
I thought it might be flakiness. |
LGTM. @swankjesse? |
* Configure this client to follow redirects. | ||
* | ||
* <p>If unset, redirects will not be followed. This is the equivalent as the | ||
* built-in {@code HttpURLConnection}'s default. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I might tweak this sentence later once this is landed. I thought in OkHttp following redirects was the default.
…t_follow_redirects Fixes the do not follow redirects bug
This PR does not add support for follow-up POST redirects. Currently the redirect is prevented in case of a POST request:
So only GET and HEAD redirects are supported. Am I wrong, or should POST requests should also fall through? |
Why? |
It’s now-obsolete advice actually.
|
@swankjesse then no redirect is done by OkHttp with any http code? I tried with OkHttp
|
Nope, we follow redirects. Just the spec was recently revised and we could track the changes. |
@swankjesse will be cool some sample or entry on FAQ for this :) |
The HttpEngine would not obey the set state because there was no
correlation between the HttpURLConnection.setInstanceFollowRedirects
method and the OkHttpClient.
Fixed the missing link by adding a new setFollowRedirects method to the
OkHttpClient class. Bridged the gap for the HttpURLConnection.setInstanceFollowRedirects
by forwarding that state into the OkHttpClient.
Now the HttpEngine will always obey the OkHttpClient redirect state when
attempting the followUp phase.
Added necessary test to both OkUrlFactoryTest and CallTest.
#943