Skip to content

Commit 174e9c4

Browse files
authored
Merge pull request cloudbees-oss#418 from aheritier/setFollowRedirect
Configure the DefaultAsyncHttpClient to follow redirects
2 parents 9190c96 + 6af821d commit 174e9c4

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/main/java/org/zendesk/client/v2/Zendesk.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.asynchttpclient.AsyncCompletionHandler;
1212
import org.asynchttpclient.AsyncHttpClient;
1313
import org.asynchttpclient.DefaultAsyncHttpClient;
14+
import org.asynchttpclient.DefaultAsyncHttpClientConfig;
1415
import org.asynchttpclient.ListenableFuture;
1516
import org.asynchttpclient.Realm;
1617
import org.asynchttpclient.Request;
@@ -102,6 +103,8 @@
102103
*/
103104
public class Zendesk implements Closeable {
104105
private static final String JSON = "application/json; charset=UTF-8";
106+
private static final DefaultAsyncHttpClientConfig DEFAULT_ASYNC_HTTP_CLIENT_CONFIG =
107+
new DefaultAsyncHttpClientConfig.Builder().setFollowRedirect(true).build();
105108
private final boolean closeClient;
106109
private final AsyncHttpClient client;
107110
private final Realm realm;
@@ -147,7 +150,7 @@ private Zendesk(AsyncHttpClient client, String url, String username, String pass
147150
this.logger = LoggerFactory.getLogger(Zendesk.class);
148151
this.closeClient = client == null;
149152
this.oauthToken = null;
150-
this.client = client == null ? new DefaultAsyncHttpClient() : client;
153+
this.client = client == null ? new DefaultAsyncHttpClient(DEFAULT_ASYNC_HTTP_CLIENT_CONFIG) : client;
151154
this.url = url.endsWith("/") ? url + "api/v2" : url + "/api/v2";
152155
if (username != null) {
153156
this.realm = new Realm.Builder(username, password)
@@ -169,7 +172,7 @@ private Zendesk(AsyncHttpClient client, String url, String oauthToken, Map<Strin
169172
this.logger = LoggerFactory.getLogger(Zendesk.class);
170173
this.closeClient = client == null;
171174
this.realm = null;
172-
this.client = client == null ? new DefaultAsyncHttpClient() : client;
175+
this.client = client == null ? new DefaultAsyncHttpClient(DEFAULT_ASYNC_HTTP_CLIENT_CONFIG) : client;
173176
this.url = url.endsWith("/") ? url + "api/v2" : url + "/api/v2";
174177
if (oauthToken != null) {
175178
this.oauthToken = oauthToken;

0 commit comments

Comments
 (0)