Skip to content

Add an option to not follow redirects (302) and add a unit test for that - #602

Merged
velo merged 3 commits into
OpenFeign:masterfrom
braincube-io:followRedirects
Apr 5, 2018
Merged

velo merged 3 commits into
OpenFeign:masterfrom
braincube-io:followRedirects

Conversation

@Gui13

@Gui13 Gui13 commented Nov 15, 2017

Copy link
Copy Markdown
Contributor

This change allows the Options() constructor to specify whether the HttpConnection should follow redirects or not. The default is yes (as has been from the beginning) but you can now specify that the connection should return the 3xx response if received.

This might fix the #249 issue. At least it solves it in my case: I wanted to receive the 302 response of the API I'm interrogating and act upon that.

@kdavisk6 kdavisk6 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@Gui13 The core changes look good. However, I think the changes in the imports may not be necessary. Can you verify that you are using the Styles outlined in CONTRIBUTING?

Also you have a conflict due to another recent change.

@Gui13
Gui13 force-pushed the followRedirects branch from c71d372 to 8fe5995 Compare March 22, 2018 08:20
@Gui13

Gui13 commented Mar 22, 2018

Copy link
Copy Markdown
Contributor Author

@kdavisk6 I have rebased on master and reworked the imports to keep it clean (my IntelliJ optimizes imports on the fly).

It should now be acceptable?

connection.setReadTimeout(options.readTimeoutMillis());
connection.setAllowUserInteraction(false);
connection.setInstanceFollowRedirects(true);
connection.setInstanceFollowRedirects(options.isFollowRedirects());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Won't this impact other clients too?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The other clients would need to be updated to use the option.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I made the option default to true, so the previous clients will keep the previous behavior.

You have to explicitely set the option to false to have the new behavior.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@velo I have added implementations for Ribbon, OkHttp and LbClient as well (since unit tests of Ribbon use it too).

@velo velo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@velo

velo commented Apr 4, 2018

Copy link
Copy Markdown
Member

One of the tests failed. Could you please take a look?

@Gui13

Gui13 commented Apr 5, 2018

Copy link
Copy Markdown
Contributor Author

I did and corrected. I just forgot to run the entire testing suite after commiting the new options.

@velo
velo merged commit c2fcbed into OpenFeign:master Apr 5, 2018
@Gui13
Gui13 deleted the followRedirects branch September 12, 2018 14:07
velo pushed a commit that referenced this pull request Oct 7, 2024
…hat (#602)

* Add an option to not follow redirects (302) and add a unit test for that

* Implement followRedirect options for Ribbon Client and OkHTTP.
Add unit tests for these.

* Fix last failing unit test with IClientConfig options handling
velo pushed a commit that referenced this pull request Oct 8, 2024
…hat (#602)

* Add an option to not follow redirects (302) and add a unit test for that

* Implement followRedirect options for Ribbon Client and OkHTTP.
Add unit tests for these.

* Fix last failing unit test with IClientConfig options handling
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants