Skip to content

Commit

Permalink
[RESTEASY-3324] Enable redirects using property.
Browse files Browse the repository at this point in the history
  • Loading branch information
The-Huginn committed Jul 19, 2023
1 parent 629570e commit 7caca71
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
13 changes: 10 additions & 3 deletions docbook/reference/en/en-US/modules/RESTEasy_Client_Framework.xml
Original file line number Diff line number Diff line change
Expand Up @@ -676,13 +676,20 @@ ApacheHttpClient43Engine engine = new ApacheHttpClient43Engine(httpClient,
}
});
</programlisting>

<section id="http_redirect">
<section id="http_redirect">
<title>HTTP redirect</title>
<para>
The <classname>ClientHttpEngine</classname> implementations based on Apache
<classname>HttpClient</classname> support HTTP redirection.
The feature is disabled by default and has to be enabled by users explicitly:
The feature is disabled by default and has to be enabled by users explicitly.
Either by setting up the following property:
<itemizedlist>
<listitem><classname>dev.resteasy.client.follow.redirects</classname></listitem>
</itemizedlist>
<programlisting>
Client client = ClientBuilder.newBuilder().property("dev.resteasy.client.follow.redirects", "true").build();
</programlisting>
or by explicitly calling the API method as following:
<programlisting>
ApacheHttpClient43Engine engine = new ApacheHttpClient43Engine();
engine.setFollowRedirects(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public enum HostnameVerificationPolicy {
*/
public static final String PROPERTY_PROXY_SCHEME = "org.jboss.resteasy.jaxrs.client.proxy.scheme";

public static final String PROPERTY_FOLLOW_REDIRECTS = "dev.resteasy.client.follow.redirects";

/**
* Changing the providerFactory will wipe clean any registered components or properties.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,11 @@ public ResteasyClient build() {
}
}

final Object localFollowRedirects = config.getProperty(PROPERTY_FOLLOW_REDIRECTS);
if (localFollowRedirects != null) {
this.followRedirects = Boolean.parseBoolean(String.valueOf(localFollowRedirects));
}

ClientHttpEngine engine = httpEngine != null ? httpEngine
: new ClientHttpEngineBuilder43().resteasyClientBuilder(this).build();
if (resetProxy) {
Expand Down

0 comments on commit 7caca71

Please sign in to comment.