Skip to content

Commit 32c74a4

Browse files
author
Stephane Landelle
committed
Port on master new Request API, close AsyncHttpClient#588
1 parent 85bb815 commit 32c74a4

File tree

67 files changed

+1539
-906
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1539
-906
lines changed

api/src/main/java/org/asynchttpclient/AsyncHttpClientConfig.java

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public class AsyncHttpClientConfig {
8585
protected int idleConnectionInPoolTimeoutInMs;
8686
protected int idleConnectionTimeoutInMs;
8787
protected int requestTimeoutInMs;
88-
protected boolean redirectEnabled;
88+
protected boolean followRedirect;
8989
protected int maxRedirects;
9090
protected boolean compressionEnabled;
9191
protected String userAgent;
@@ -101,7 +101,7 @@ public class AsyncHttpClientConfig {
101101
protected int requestCompressionLevel;
102102
protected int maxRequestRetry;
103103
protected boolean allowSslConnectionPool;
104-
protected boolean useRawUrl;
104+
protected boolean disableUrlEncodingForBoundRequests;
105105
protected boolean removeQueryParamOnRedirect;
106106
protected HostnameVerifier hostnameVerifier;
107107
protected int ioThreadMultiplier;
@@ -125,7 +125,7 @@ private AsyncHttpClientConfig(int maxTotalConnections, //
125125
int idleConnectionTimeoutInMs, //
126126
int requestTimeoutInMs, //
127127
int connectionMaxLifeTimeInMs, //
128-
boolean redirectEnabled, //
128+
boolean followRedirect, //
129129
int maxRedirects, //
130130
boolean compressionEnabled, //
131131
String userAgent, //
@@ -143,7 +143,7 @@ private AsyncHttpClientConfig(int maxTotalConnections, //
143143
int requestCompressionLevel, //
144144
int maxRequestRetry, //
145145
boolean allowSslConnectionCaching, //
146-
boolean useRawUrl, //
146+
boolean disableUrlEncodingForBoundRequests, //
147147
boolean removeQueryParamOnRedirect, //
148148
HostnameVerifier hostnameVerifier, //
149149
int ioThreadMultiplier, //
@@ -163,7 +163,7 @@ private AsyncHttpClientConfig(int maxTotalConnections, //
163163
this.idleConnectionTimeoutInMs = idleConnectionTimeoutInMs;
164164
this.requestTimeoutInMs = requestTimeoutInMs;
165165
this.maxConnectionLifeTimeInMs = connectionMaxLifeTimeInMs;
166-
this.redirectEnabled = redirectEnabled;
166+
this.followRedirect = followRedirect;
167167
this.maxRedirects = maxRedirects;
168168
this.compressionEnabled = compressionEnabled;
169169
this.userAgent = userAgent;
@@ -184,7 +184,7 @@ private AsyncHttpClientConfig(int maxTotalConnections, //
184184
this.useRelativeURIsWithSSLProxies = useRelativeURIsWithSSLProxies;
185185
this.applicationThreadPool = applicationThreadPool;
186186
this.proxyServerSelector = proxyServerSelector;
187-
this.useRawUrl = useRawUrl;
187+
this.disableUrlEncodingForBoundRequests = disableUrlEncodingForBoundRequests;
188188
this.spdyEnabled = spdyEnabled;
189189
this.spdyInitialWindowSize = spdyInitialWindowSize;
190190
this.spdyMaxConcurrentStreams = spdyMaxConcurrentStreams;
@@ -262,8 +262,8 @@ public int getRequestTimeoutInMs() {
262262
*
263263
* @return true if enabled.
264264
*/
265-
public boolean isRedirectEnabled() {
266-
return redirectEnabled;
265+
public boolean isFollowRedirect() {
266+
return followRedirect;
267267
}
268268

269269
/**
@@ -422,10 +422,10 @@ public boolean isSslConnectionPoolEnabled() {
422422
}
423423

424424
/**
425-
* @return the useRawUrl
425+
* @return the disableUrlEncodingForBoundRequests
426426
*/
427-
public boolean isUseRawUrl() {
428-
return useRawUrl;
427+
public boolean isDisableUrlEncodingForBoundRequests() {
428+
return disableUrlEncodingForBoundRequests;
429429
}
430430

431431
/**
@@ -552,7 +552,7 @@ public static class Builder {
552552
private int idleConnectionTimeoutInMs = defaultIdleConnectionTimeoutInMs();
553553
private int requestTimeoutInMs = defaultRequestTimeoutInMs();
554554
private int maxConnectionLifeTimeInMs = defaultMaxConnectionLifeTimeInMs();
555-
private boolean redirectEnabled = defaultRedirectEnabled();
555+
private boolean followRedirect = defaultFollowRedirect();
556556
private int maxRedirects = defaultMaxRedirects();
557557
private boolean compressionEnabled = defaultCompressionEnabled();
558558
private String userAgent = defaultUserAgent();
@@ -564,7 +564,7 @@ public static class Builder {
564564
private int maxRequestRetry = defaultMaxRequestRetry();
565565
private int ioThreadMultiplier = defaultIoThreadMultiplier();
566566
private boolean allowSslConnectionPool = defaultAllowSslConnectionPool();
567-
private boolean useRawUrl = defaultUseRawUrl();
567+
private boolean disableUrlEncodingForBoundRequests = defaultDisableUrlEncodingForBoundRequests();
568568
private boolean removeQueryParamOnRedirect = defaultRemoveQueryParamOnRedirect();
569569
private boolean strict302Handling = defaultStrict302Handling();
570570
private HostnameVerifier hostnameVerifier = defaultHostnameVerifier();
@@ -676,8 +676,8 @@ public Builder setRequestTimeoutInMs(int requestTimeoutInMs) {
676676
* @param redirectEnabled true if enabled.
677677
* @return a {@link Builder}
678678
*/
679-
public Builder setFollowRedirects(boolean redirectEnabled) {
680-
this.redirectEnabled = redirectEnabled;
679+
public Builder setFollowRedirects(boolean followRedirect) {
680+
this.followRedirect = followRedirect;
681681
return this;
682682
}
683683

@@ -933,11 +933,11 @@ public Builder setAllowSslConnectionPool(boolean allowSslConnectionPool) {
933933
* Allows use unescaped URLs in requests
934934
* useful for retrieving data from broken sites
935935
*
936-
* @param useRawUrl
936+
* @param disableUrlEncodingForBoundRequests
937937
* @return this
938938
*/
939-
public Builder setUseRawUrl(boolean useRawUrl) {
940-
this.useRawUrl = useRawUrl;
939+
public Builder setDisableUrlEncodingForBoundRequests(boolean disableUrlEncodingForBoundRequests) {
940+
this.disableUrlEncodingForBoundRequests = disableUrlEncodingForBoundRequests;
941941
return this;
942942
}
943943

@@ -1111,7 +1111,7 @@ public Builder(AsyncHttpClientConfig prototype) {
11111111
requestTimeoutInMs = prototype.getRequestTimeoutInMs();
11121112
sslContext = prototype.getSSLContext();
11131113
userAgent = prototype.getUserAgent();
1114-
redirectEnabled = prototype.isRedirectEnabled();
1114+
followRedirect = prototype.isFollowRedirect();
11151115
compressionEnabled = prototype.isCompressionEnabled();
11161116
applicationThreadPool = prototype.executorService();
11171117

@@ -1124,7 +1124,7 @@ public Builder(AsyncHttpClientConfig prototype) {
11241124
ioExceptionFilters.addAll(prototype.getIOExceptionFilters());
11251125

11261126
requestCompressionLevel = prototype.getRequestCompressionLevel();
1127-
useRawUrl = prototype.isUseRawUrl();
1127+
disableUrlEncodingForBoundRequests = prototype.isDisableUrlEncodingForBoundRequests();
11281128
ioThreadMultiplier = prototype.getIoThreadMultiplier();
11291129
maxRequestRetry = prototype.getMaxRequestRetry();
11301130
allowSslConnectionPool = prototype.getAllowPoolingConnection();
@@ -1172,7 +1172,7 @@ public Thread newThread(Runnable r) {
11721172
idleConnectionTimeoutInMs, //
11731173
requestTimeoutInMs, //
11741174
maxConnectionLifeTimeInMs, //
1175-
redirectEnabled, //
1175+
followRedirect, //
11761176
maxRedirects, //
11771177
compressionEnabled, //
11781178
userAgent, //
@@ -1190,7 +1190,7 @@ public Thread newThread(Runnable r) {
11901190
requestCompressionLevel, //
11911191
maxRequestRetry, //
11921192
allowSslConnectionPool, //
1193-
useRawUrl, //
1193+
disableUrlEncodingForBoundRequests, //
11941194
removeQueryParamOnRedirect, //
11951195
hostnameVerifier, //
11961196
ioThreadMultiplier, //

api/src/main/java/org/asynchttpclient/AsyncHttpClientConfigBean.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void configureDefaults() {
5353
idleConnectionTimeoutInMs = defaultIdleConnectionTimeoutInMs();
5454
requestTimeoutInMs = defaultRequestTimeoutInMs();
5555
maxConnectionLifeTimeInMs = defaultMaxConnectionLifeTimeInMs();
56-
redirectEnabled = defaultRedirectEnabled();
56+
followRedirect = defaultFollowRedirect();
5757
maxRedirects = defaultMaxRedirects();
5858
compressionEnabled = defaultCompressionEnabled();
5959
userAgent = defaultUserAgent();
@@ -63,7 +63,7 @@ void configureDefaults() {
6363
maxRequestRetry = defaultMaxRequestRetry();
6464
ioThreadMultiplier = defaultIoThreadMultiplier();
6565
allowSslConnectionPool = defaultAllowSslConnectionPool();
66-
useRawUrl = defaultUseRawUrl();
66+
disableUrlEncodingForBoundRequests = defaultDisableUrlEncodingForBoundRequests();
6767
removeQueryParamOnRedirect = defaultRemoveQueryParamOnRedirect();
6868
strict302Handling = defaultStrict302Handling();
6969
hostnameVerifier = defaultHostnameVerifier();
@@ -123,8 +123,8 @@ public AsyncHttpClientConfigBean setRequestTimeoutInMs(int requestTimeoutInMs) {
123123
return this;
124124
}
125125

126-
public AsyncHttpClientConfigBean setRedirectEnabled(boolean redirectEnabled) {
127-
this.redirectEnabled = redirectEnabled;
126+
public AsyncHttpClientConfigBean setFollowRedirect(boolean followRedirect) {
127+
this.followRedirect = followRedirect;
128128
return this;
129129
}
130130

@@ -216,8 +216,8 @@ public AsyncHttpClientConfigBean setAllowSslConnectionPool(boolean allowSslConne
216216
return this;
217217
}
218218

219-
public AsyncHttpClientConfigBean setUseRawUrl(boolean useRawUrl) {
220-
this.useRawUrl = useRawUrl;
219+
public AsyncHttpClientConfigBean setDisableUrlEncodingForBoundRequests(boolean disableUrlEncodingForBoundRequests) {
220+
this.disableUrlEncodingForBoundRequests = disableUrlEncodingForBoundRequests;
221221
return this;
222222
}
223223

api/src/main/java/org/asynchttpclient/AsyncHttpClientConfigDefaults.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ public static int defaultMaxConnectionLifeTimeInMs() {
5757
return Integer.getInteger(ASYNC_CLIENT + "maxConnectionLifeTimeInMs", -1);
5858
}
5959

60-
public static boolean defaultRedirectEnabled() {
61-
return Boolean.getBoolean(ASYNC_CLIENT + "redirectsEnabled");
60+
public static boolean defaultFollowRedirect() {
61+
return Boolean.getBoolean(ASYNC_CLIENT + "followRedirect");
6262
}
6363

6464
public static int defaultMaxRedirects() {
@@ -110,8 +110,8 @@ public static boolean defaultAllowSslConnectionPool() {
110110
return getBoolean(ASYNC_CLIENT + "allowSslConnectionPool", true);
111111
}
112112

113-
public static boolean defaultUseRawUrl() {
114-
return Boolean.getBoolean(ASYNC_CLIENT + "useRawUrl");
113+
public static boolean defaultDisableUrlEncodingForBoundRequests() {
114+
return Boolean.getBoolean(ASYNC_CLIENT + "disableUrlEncodingForBoundRequests");
115115
}
116116

117117
public static boolean defaultRemoveQueryParamOnRedirect() {

api/src/main/java/org/asynchttpclient/BoundRequestBuilder.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@
1818
import java.io.IOException;
1919
import java.io.InputStream;
2020
import java.util.Collection;
21+
import java.util.List;
2122
import java.util.Map;
2223

2324
public class BoundRequestBuilder extends RequestBuilderBase<BoundRequestBuilder> {
2425

2526
private final AsyncHttpClient client;
2627

27-
public BoundRequestBuilder(AsyncHttpClient client, String reqType, boolean useRawUrl) {
28-
super(BoundRequestBuilder.class, reqType, useRawUrl);
28+
public BoundRequestBuilder(AsyncHttpClient client, String method, boolean isDisableUrlEncoding) {
29+
super(BoundRequestBuilder.class, method, isDisableUrlEncoding);
2930
this.client = client;
3031
}
3132

@@ -42,9 +43,10 @@ public ListenableFuture<Response> execute() throws IOException {
4243
return client.executeRequest(build(), new AsyncCompletionHandlerBase());
4344
}
4445

45-
// Note: For now we keep the delegates in place even though they are not needed
46-
// since otherwise Clojure (and maybe other languages) won't be able to
47-
// access these methods - see Clojure tickets 126 and 259
46+
// Note: For now we keep the delegates in place even though they are not
47+
// needed
48+
// since otherwise Clojure (and maybe other languages) won't be able to
49+
// access these methods - see Clojure tickets 126 and 259
4850

4951
@Override
5052
public BoundRequestBuilder addBodyPart(Part part) {
@@ -62,13 +64,13 @@ public BoundRequestBuilder addHeader(String name, String value) {
6264
}
6365

6466
@Override
65-
public BoundRequestBuilder addParameter(String key, String value) {
66-
return super.addParameter(key, value);
67+
public BoundRequestBuilder addFormParam(String key, String value) {
68+
return super.addFormParam(key, value);
6769
}
6870

6971
@Override
70-
public BoundRequestBuilder addQueryParameter(String name, String value) {
71-
return super.addQueryParameter(name, value);
72+
public BoundRequestBuilder addQueryParam(String name, String value) {
73+
return super.addQueryParam(name, value);
7274
}
7375

7476
@Override
@@ -107,13 +109,13 @@ public BoundRequestBuilder setHeaders(Map<String, Collection<String>> headers) {
107109
}
108110

109111
@Override
110-
public BoundRequestBuilder setParameters(Map<String, Collection<String>> parameters) {
111-
return super.setParameters(parameters);
112+
public BoundRequestBuilder setFormParams(Map<String, List<String>> params) {
113+
return super.setFormParams(params);
112114
}
113115

114116
@Override
115-
public BoundRequestBuilder setParameters(FluentStringsMap parameters) {
116-
return super.setParameters(parameters);
117+
public BoundRequestBuilder setFormParams(List<Param> params) {
118+
return super.setFormParams(params);
117119
}
118120

119121
@Override
@@ -126,7 +128,6 @@ public BoundRequestBuilder setVirtualHost(String virtualHost) {
126128
return super.setVirtualHost(virtualHost);
127129
}
128130

129-
@Override
130131
public BoundRequestBuilder setSignatureCalculator(SignatureCalculator signatureCalculator) {
131132
return super.setSignatureCalculator(signatureCalculator);
132133
}

api/src/main/java/org/asynchttpclient/ConnectionPoolKeyStrategy.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
*/
1616
package org.asynchttpclient;
1717

18-
import java.net.URI;
18+
import org.asynchttpclient.uri.UriComponents;
1919

2020
public interface ConnectionPoolKeyStrategy {
2121

22-
String getKey(URI uri, ProxyServer proxy);
22+
String getKey(UriComponents uri, ProxyServer proxy);
2323
}

api/src/main/java/org/asynchttpclient/DefaultAsyncHttpClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,8 @@ private static AsyncHttpProvider loadDefaultProvider(String[] providerClassNames
311311
throw new IllegalStateException("No providers found on the classpath");
312312
}
313313

314-
protected BoundRequestBuilder requestBuilder(String reqType, String url) {
315-
return new BoundRequestBuilder(this, reqType, config.isUseRawUrl()).setUrl(url).setSignatureCalculator(signatureCalculator);
314+
protected BoundRequestBuilder requestBuilder(String method, String url) {
315+
return new BoundRequestBuilder(this, method, config.isDisableUrlEncodingForBoundRequests()).setUrl(url).setSignatureCalculator(signatureCalculator);
316316
}
317317

318318
protected BoundRequestBuilder requestBuilder(Request prototype) {

api/src/main/java/org/asynchttpclient/DefaultConnectionPoolStrategy.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,15 @@
1515
*/
1616
package org.asynchttpclient;
1717

18+
import org.asynchttpclient.uri.UriComponents;
1819
import org.asynchttpclient.util.AsyncHttpProviderUtils;
1920

20-
import java.net.URI;
21-
2221
public enum DefaultConnectionPoolStrategy implements ConnectionPoolKeyStrategy {
2322

2423
INSTANCE;
2524

2625
@Override
27-
public String getKey(URI uri, ProxyServer proxyServer) {
26+
public String getKey(UriComponents uri, ProxyServer proxyServer) {
2827
String serverPart = AsyncHttpProviderUtils.getBaseUrl(uri);
2928
return proxyServer != null ? proxyServer.getUrl() + serverPart : serverPart;
3029
}

0 commit comments

Comments
 (0)