Skip to content
Commits on Source (12)
async-http-client (1.8.2-1) UNRELEASED; urgency=medium
async-http-client (1.8.12-1) UNRELEASED; urgency=medium
* Team upload.
* New upstream release
......
......@@ -5,7 +5,7 @@ Forwarded: not-needed
Bug-Debian: http://bugs.debian.org/773372
--- a/src/main/java/com/ning/http/client/FluentStringsMap.java
+++ b/src/main/java/com/ning/http/client/FluentStringsMap.java
@@ -128,7 +128,7 @@
@@ -139,7 +139,7 @@
* @return This object
*/
public FluentStringsMap replace(final String key, final String... values) {
......@@ -16,7 +16,7 @@ Bug-Debian: http://bugs.debian.org/773372
/**
--- a/src/main/java/com/ning/http/client/FluentCaseInsensitiveStringsMap.java
+++ b/src/main/java/com/ning/http/client/FluentCaseInsensitiveStringsMap.java
@@ -165,7 +165,7 @@
@@ -184,7 +184,7 @@
* @return This object
*/
public FluentCaseInsensitiveStringsMap replace(final String key, final String... values) {
......
......@@ -3,13 +3,13 @@
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>5</version>
<version>9</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.ning</groupId>
<artifactId>async-http-client</artifactId>
<name>Asynchronous Http Client</name>
<version>1.8.2</version>
<version>1.8.12</version>
<packaging>jar</packaging>
<description>
Async Http Client library purpose is to allow Java applications to easily execute HTTP requests and
......@@ -81,7 +81,7 @@
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty</artifactId>
<version>3.9.0.Final</version>
<version>3.9.2.Final</version>
</dependency>
<dependency>
......@@ -394,38 +394,38 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>shaded</shadedClassifierName>
<artifactSet>
<excludes>
<exclude>commons-codec:commons-codec</exclude>
<exclude>commons-lang:commons-lang</exclude>
<exclude>commons-logging:commons-logging</exclude>
<exclude>junit:junit</exclude>
<exclude>log4j:log4j</exclude>
<exclude>commons-httpclient:commons-httpclient</exclude>
</excludes>
</artifactSet>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
<transformer implementation="org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer" />
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer" />
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<!-- <plugin> -->
<!-- <groupId>org.apache.maven.plugins</groupId> -->
<!-- <artifactId>maven-shade-plugin</artifactId> -->
<!-- <version>1.2.1</version> -->
<!-- <executions> -->
<!-- <execution> -->
<!-- <phase>package</phase> -->
<!-- <goals> -->
<!-- <goal>shade</goal> -->
<!-- </goals> -->
<!-- <configuration> -->
<!-- <shadedArtifactAttached>true</shadedArtifactAttached> -->
<!-- <shadedClassifierName>shaded</shadedClassifierName> -->
<!-- <artifactSet> -->
<!-- <excludes> -->
<!-- <exclude>commons-codec:commons-codec</exclude> -->
<!-- <exclude>commons-lang:commons-lang</exclude> -->
<!-- <exclude>commons-logging:commons-logging</exclude> -->
<!-- <exclude>junit:junit</exclude> -->
<!-- <exclude>log4j:log4j</exclude> -->
<!-- <exclude>commons-httpclient:commons-httpclient</exclude> -->
<!-- </excludes> -->
<!-- </artifactSet> -->
<!-- <transformers> -->
<!-- <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" /> -->
<!-- <transformer implementation="org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer" /> -->
<!-- <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer" /> -->
<!-- </transformers> -->
<!-- </configuration> -->
<!-- </execution> -->
<!-- </executions> -->
<!-- </plugin> -->
</plugins>
</build>
<reporting>
......@@ -489,13 +489,13 @@
<dependency>
<groupId>org.glassfish.grizzly</groupId>
<artifactId>grizzly-websockets</artifactId>
<version>2.3.11</version>
<version>${grizzly.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.glassfish.grizzly</groupId>
<artifactId>grizzly-http-server</artifactId>
<version>2.3.11</version>
<version>${grizzly.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
......@@ -591,6 +591,7 @@
<compiler.exclude>com/ning/http/client/providers/grizzly/*.java</compiler.exclude>
<test.compiler.exclude>com/ning/http/client/async/grizzly/*.java</test.compiler.exclude>
<javadoc.package.exclude>com.ning.http.client.providers.grizzly</javadoc.package.exclude>
<grizzly.version>2.3.14</grizzly.version>
<source.property>1.5</source.property>
<target.property>1.5</target.property>
<surefire.version>2.12</surefire.version>
......
......@@ -212,17 +212,6 @@ public class AsyncHttpClient implements Closeable {
}
public class BoundRequestBuilder extends RequestBuilderBase<BoundRequestBuilder> {
/**
* Calculator used for calculating request signature for the request being
* built, if any.
*/
protected SignatureCalculator signatureCalculator;
/**
* URL used as the base, not including possibly query parameters. Needed for
* signature calculation
*/
protected String baseURL;
private BoundRequestBuilder(String reqType, boolean useRawUrl) {
super(BoundRequestBuilder.class, reqType, useRawUrl);
......@@ -245,7 +234,7 @@ public class AsyncHttpClient implements Closeable {
// access these methods - see Clojure tickets 126 and 259
@Override
public BoundRequestBuilder addBodyPart(Part part) throws IllegalArgumentException {
public BoundRequestBuilder addBodyPart(Part part) {
return super.addBodyPart(part);
}
......@@ -260,7 +249,7 @@ public class AsyncHttpClient implements Closeable {
}
@Override
public BoundRequestBuilder addParameter(String key, String value) throws IllegalArgumentException {
public BoundRequestBuilder addParameter(String key, String value) {
return super.addParameter(key, value);
}
......@@ -271,28 +260,16 @@ public class AsyncHttpClient implements Closeable {
@Override
public Request build() {
/* Let's first calculate and inject signature, before finalizing actual build
* (order does not matter with current implementation but may in future)
*/
if (signatureCalculator != null) {
String url = baseURL;
// Should not include query parameters, ensure:
int i = url.indexOf('?');
if (i >= 0) {
url = url.substring(0, i);
}
signatureCalculator.calculateAndAddSignature(url, request, this);
}
return super.build();
}
@Override
public BoundRequestBuilder setBody(byte[] data) throws IllegalArgumentException {
public BoundRequestBuilder setBody(byte[] data) {
return super.setBody(data);
}
@Override
public BoundRequestBuilder setBody(EntityWriter dataWriter, long length) throws IllegalArgumentException {
public BoundRequestBuilder setBody(EntityWriter dataWriter, long length) {
return super.setBody(dataWriter, length);
}
......@@ -302,12 +279,12 @@ public class AsyncHttpClient implements Closeable {
}
@Override
public BoundRequestBuilder setBody(InputStream stream) throws IllegalArgumentException {
public BoundRequestBuilder setBody(InputStream stream) {
return super.setBody(stream);
}
@Override
public BoundRequestBuilder setBody(String data) throws IllegalArgumentException {
public BoundRequestBuilder setBody(String data) {
return super.setBody(data);
}
......@@ -327,18 +304,17 @@ public class AsyncHttpClient implements Closeable {
}
@Override
public BoundRequestBuilder setParameters(Map<String, Collection<String>> parameters) throws IllegalArgumentException {
public BoundRequestBuilder setParameters(Map<String, Collection<String>> parameters) {
return super.setParameters(parameters);
}
@Override
public BoundRequestBuilder setParameters(FluentStringsMap parameters) throws IllegalArgumentException {
public BoundRequestBuilder setParameters(FluentStringsMap parameters) {
return super.setParameters(parameters);
}
@Override
public BoundRequestBuilder setUrl(String url) {
baseURL = url;
return super.setUrl(url);
}
......@@ -348,8 +324,7 @@ public class AsyncHttpClient implements Closeable {
}
public BoundRequestBuilder setSignatureCalculator(SignatureCalculator signatureCalculator) {
this.signatureCalculator = signatureCalculator;
return this;
return super.setSignatureCalculator(signatureCalculator);
}
}
......
......@@ -15,11 +15,12 @@
*/
package com.ning.http.client;
import static com.ning.http.client.AsyncHttpClientConfigDefaults.*;
import com.ning.http.client.date.TimeConverter;
import com.ning.http.client.filter.IOExceptionFilter;
import com.ning.http.client.filter.RequestFilter;
import com.ning.http.client.filter.ResponseFilter;
import com.ning.http.util.AllowAllHostnameVerifier;
import com.ning.http.util.ProxyUtils;
import javax.net.ssl.HostnameVerifier;
......@@ -52,8 +53,6 @@ import java.util.concurrent.ThreadFactory;
*/
public class AsyncHttpClientConfig {
protected final static String ASYNC_CLIENT = AsyncHttpClientConfig.class.getName() + ".";
protected int maxTotalConnections;
protected int maxConnectionPerHost;
protected int connectionTimeOutInMs;
......@@ -62,7 +61,7 @@ public class AsyncHttpClientConfig {
protected int idleConnectionTimeoutInMs;
protected int requestTimeoutInMs;
protected boolean redirectEnabled;
protected int maxDefaultRedirects;
protected int maxRedirects;
protected boolean compressionEnabled;
protected String userAgent;
protected boolean allowPoolingConnection;
......@@ -100,7 +99,7 @@ public class AsyncHttpClientConfig {
int requestTimeoutInMs,
int connectionMaxLifeTimeInMs,
boolean redirectEnabled,
int maxDefaultRedirects,
int maxRedirects,
boolean compressionEnabled,
String userAgent,
boolean keepAlive,
......@@ -133,7 +132,7 @@ public class AsyncHttpClientConfig {
this.requestTimeoutInMs = requestTimeoutInMs;
this.maxConnectionLifeTimeInMs = connectionMaxLifeTimeInMs;
this.redirectEnabled = redirectEnabled;
this.maxDefaultRedirects = maxDefaultRedirects;
this.maxRedirects = maxRedirects;
this.compressionEnabled = compressionEnabled;
this.userAgent = userAgent;
this.allowPoolingConnection = keepAlive;
......@@ -243,7 +242,7 @@ public class AsyncHttpClientConfig {
* @return the maximum number of HTTP redirect
*/
public int getMaxRedirects() {
return maxDefaultRedirects;
return maxRedirects;
}
/**
......@@ -524,22 +523,31 @@ public class AsyncHttpClientConfig {
* Builder for an {@link AsyncHttpClient}
*/
public static class Builder {
private int defaultMaxTotalConnections = Integer.getInteger(ASYNC_CLIENT + "defaultMaxTotalConnections", -1);
private int defaultMaxConnectionPerHost = Integer.getInteger(ASYNC_CLIENT + "defaultMaxConnectionsPerHost", -1);
private int defaultConnectionTimeOutInMs = Integer.getInteger(ASYNC_CLIENT + "defaultConnectionTimeoutInMS", 60 * 1000);
private int defaultWebsocketIdleTimeoutInMs = Integer.getInteger(ASYNC_CLIENT + "defaultWebsocketTimoutInMS", 15 * 60 * 1000);
private int defaultIdleConnectionInPoolTimeoutInMs = Integer.getInteger(ASYNC_CLIENT + "defaultIdleConnectionInPoolTimeoutInMS", 60 * 1000);
private int defaultIdleConnectionTimeoutInMs = Integer.getInteger(ASYNC_CLIENT + "defaultIdleConnectionTimeoutInMS", 60 * 1000);
private int defaultRequestTimeoutInMs = Integer.getInteger(ASYNC_CLIENT + "defaultRequestTimeoutInMS", 60 * 1000);
private int defaultMaxConnectionLifeTimeInMs = Integer.getInteger(ASYNC_CLIENT + "defaultMaxConnectionLifeTimeInMs", -1);
private boolean redirectEnabled = Boolean.getBoolean(ASYNC_CLIENT + "defaultRedirectsEnabled");
private int maxDefaultRedirects = Integer.getInteger(ASYNC_CLIENT + "defaultMaxRedirects", 5);
private boolean compressionEnabled = Boolean.getBoolean(ASYNC_CLIENT + "compressionEnabled");
private String userAgent = System.getProperty(ASYNC_CLIENT + "userAgent", "NING/1.0");
private boolean useProxyProperties = Boolean.getBoolean(ASYNC_CLIENT + "useProxyProperties");
private boolean useProxySelector = Boolean.getBoolean(ASYNC_CLIENT + "useProxySelector");
private boolean allowPoolingConnection = true;
private boolean useRelativeURIsWithSSLProxies = Boolean.getBoolean(ASYNC_CLIENT + "useRelativeURIsWithSSLProxies");
private int maxTotalConnections = defaultMaxTotalConnections();
private int maxConnectionPerHost = defaultMaxConnectionPerHost();
private int connectionTimeOutInMs = defaultConnectionTimeOutInMs();
private int webSocketIdleTimeoutInMs = defaultWebSocketIdleTimeoutInMs();
private int idleConnectionInPoolTimeoutInMs = defaultIdleConnectionInPoolTimeoutInMs();
private int idleConnectionTimeoutInMs = defaultIdleConnectionTimeoutInMs();
private int requestTimeoutInMs = defaultRequestTimeoutInMs();
private int maxConnectionLifeTimeInMs = defaultMaxConnectionLifeTimeInMs();
private boolean redirectEnabled = defaultRedirectEnabled();
private int maxDefaultRedirects = defaultMaxRedirects();
private boolean compressionEnabled = defaultCompressionEnabled();
private String userAgent = defaultUserAgent();
private boolean useProxyProperties = defaultUseProxyProperties();
private boolean useProxySelector = defaultUseProxySelector();
private boolean allowPoolingConnection = defaultAllowPoolingConnection();
private boolean useRelativeURIsWithSSLProxies = defaultUseRelativeURIsWithSSLProxies();
private int requestCompressionLevel = defaultRequestCompressionLevel();
private int maxRequestRetry = defaultMaxRequestRetry();
private int ioThreadMultiplier = defaultIoThreadMultiplier();
private boolean allowSslConnectionPool = defaultAllowSslConnectionPool();
private boolean useRawUrl = defaultUseRawUrl();
private boolean removeQueryParamOnRedirect = defaultRemoveQueryParamOnRedirect();
private boolean strict302Handling = defaultStrict302Handling();
private HostnameVerifier hostnameVerifier = defaultHostnameVerifier();
private ExecutorService applicationThreadPool;
private ProxyServerSelector proxyServerSelector = null;
private SSLContext sslContext;
......@@ -547,17 +555,9 @@ public class AsyncHttpClientConfig {
private AsyncHttpProviderConfig<?, ?> providerConfig;
private ConnectionsPool<?, ?> connectionsPool;
private Realm realm;
private int requestCompressionLevel = -1;
private int maxRequestRetry = 5;
private final List<RequestFilter> requestFilters = new LinkedList<RequestFilter>();
private final List<ResponseFilter> responseFilters = new LinkedList<ResponseFilter>();
private final List<IOExceptionFilter> ioExceptionFilters = new LinkedList<IOExceptionFilter>();
private boolean allowSslConnectionPool = true;
private boolean useRawUrl = false;
private boolean removeQueryParamOnRedirect = true;
private HostnameVerifier hostnameVerifier = new AllowAllHostnameVerifier();
private int ioThreadMultiplier = 2;
private boolean strict302Handling;
private TimeConverter timeConverter;
public Builder() {
......@@ -566,57 +566,57 @@ public class AsyncHttpClientConfig {
/**
* Set the maximum number of connections an {@link com.ning.http.client.AsyncHttpClient} can handle.
*
* @param defaultMaxTotalConnections the maximum number of connections an {@link com.ning.http.client.AsyncHttpClient} can handle.
* @param maxTotalConnections the maximum number of connections an {@link com.ning.http.client.AsyncHttpClient} can handle.
* @return a {@link Builder}
*/
public Builder setMaximumConnectionsTotal(int defaultMaxTotalConnections) {
this.defaultMaxTotalConnections = defaultMaxTotalConnections;
public Builder setMaximumConnectionsTotal(int maxTotalConnections) {
this.maxTotalConnections = maxTotalConnections;
return this;
}
/**
* Set the maximum number of connections per hosts an {@link com.ning.http.client.AsyncHttpClient} can handle.
*
* @param defaultMaxConnectionPerHost the maximum number of connections per host an {@link com.ning.http.client.AsyncHttpClient} can handle.
* @param maxConnectionPerHost the maximum number of connections per host an {@link com.ning.http.client.AsyncHttpClient} can handle.
* @return a {@link Builder}
*/
public Builder setMaximumConnectionsPerHost(int defaultMaxConnectionPerHost) {
this.defaultMaxConnectionPerHost = defaultMaxConnectionPerHost;
public Builder setMaximumConnectionsPerHost(int maxConnectionPerHost) {
this.maxConnectionPerHost = maxConnectionPerHost;
return this;
}
/**
* Set the maximum time in millisecond an {@link com.ning.http.client.AsyncHttpClient} can wait when connecting to a remote host
*
* @param defaultConnectionTimeOutInMs the maximum time in millisecond an {@link com.ning.http.client.AsyncHttpClient} can wait when connecting to a remote host
* @param connectionTimeOutInMs the maximum time in millisecond an {@link com.ning.http.client.AsyncHttpClient} can wait when connecting to a remote host
* @return a {@link Builder}
*/
public Builder setConnectionTimeoutInMs(int defaultConnectionTimeOutInMs) {
this.defaultConnectionTimeOutInMs = defaultConnectionTimeOutInMs;
public Builder setConnectionTimeoutInMs(int connectionTimeOutInMs) {
this.connectionTimeOutInMs = connectionTimeOutInMs;
return this;
}
/**
* Set the maximum time in millisecond an {@link com.ning.http.client.websocket.WebSocket} can stay idle.
*
* @param defaultWebSocketIdleTimeoutInMs
* @param webSocketIdleTimeoutInMs
* the maximum time in millisecond an {@link com.ning.http.client.websocket.WebSocket} can stay idle.
* @return a {@link Builder}
*/
public Builder setWebSocketIdleTimeoutInMs(int defaultWebSocketIdleTimeoutInMs) {
this.defaultWebsocketIdleTimeoutInMs = defaultWebSocketIdleTimeoutInMs;
public Builder setWebSocketIdleTimeoutInMs(int webSocketIdleTimeoutInMs) {
this.webSocketIdleTimeoutInMs = webSocketIdleTimeoutInMs;
return this;
}
/**
* Set the maximum time in millisecond an {@link com.ning.http.client.AsyncHttpClient} can stay idle.
*
* @param defaultIdleConnectionTimeoutInMs
* @param idleConnectionTimeoutInMs
* the maximum time in millisecond an {@link com.ning.http.client.AsyncHttpClient} can stay idle.
* @return a {@link Builder}
*/
public Builder setIdleConnectionTimeoutInMs(int defaultIdleConnectionTimeoutInMs) {
this.defaultIdleConnectionTimeoutInMs = defaultIdleConnectionTimeoutInMs;
public Builder setIdleConnectionTimeoutInMs(int idleConnectionTimeoutInMs) {
this.idleConnectionTimeoutInMs = idleConnectionTimeoutInMs;
return this;
}
......@@ -624,24 +624,24 @@ public class AsyncHttpClientConfig {
* Set the maximum time in millisecond an {@link com.ning.http.client.AsyncHttpClient} will keep connection
* idle in pool.
*
* @param defaultIdleConnectionInPoolTimeoutInMs
* @param idleConnectionInPoolTimeoutInMs
* the maximum time in millisecond an {@link com.ning.http.client.AsyncHttpClient} will keep connection
* idle in pool.
* @return a {@link Builder}
*/
public Builder setIdleConnectionInPoolTimeoutInMs(int defaultIdleConnectionInPoolTimeoutInMs) {
this.defaultIdleConnectionInPoolTimeoutInMs = defaultIdleConnectionInPoolTimeoutInMs;
public Builder setIdleConnectionInPoolTimeoutInMs(int idleConnectionInPoolTimeoutInMs) {
this.idleConnectionInPoolTimeoutInMs = idleConnectionInPoolTimeoutInMs;
return this;
}
/**
* Set the maximum time in millisecond an {@link com.ning.http.client.AsyncHttpClient} wait for a response
*
* @param defaultRequestTimeoutInMs the maximum time in millisecond an {@link com.ning.http.client.AsyncHttpClient} wait for a response
* @param requestTimeoutInMs the maximum time in millisecond an {@link com.ning.http.client.AsyncHttpClient} wait for a response
* @return a {@link Builder}
*/
public Builder setRequestTimeoutInMs(int defaultRequestTimeoutInMs) {
this.defaultRequestTimeoutInMs = defaultRequestTimeoutInMs;
public Builder setRequestTimeoutInMs(int requestTimeoutInMs) {
this.requestTimeoutInMs = requestTimeoutInMs;
return this;
}
......@@ -1024,12 +1024,13 @@ public class AsyncHttpClientConfig {
* @return a {@link Builder}
*/
public Builder setMaxConnectionLifeTimeInMs(int maxConnectionLifeTimeInMs) {
this.defaultMaxConnectionLifeTimeInMs = maxConnectionLifeTimeInMs;
this.maxConnectionLifeTimeInMs = maxConnectionLifeTimeInMs;
return this;
}
public void setTimeConverter(TimeConverter timeConverter) {
public Builder setTimeConverter(TimeConverter timeConverter) {
this.timeConverter = timeConverter;
return this;
}
/**
......@@ -1041,16 +1042,16 @@ public class AsyncHttpClientConfig {
allowPoolingConnection = prototype.getAllowPoolingConnection();
providerConfig = prototype.getAsyncHttpProviderConfig();
connectionsPool = prototype.getConnectionsPool();
defaultConnectionTimeOutInMs = prototype.getConnectionTimeoutInMs();
defaultIdleConnectionInPoolTimeoutInMs = prototype.getIdleConnectionInPoolTimeoutInMs();
defaultIdleConnectionTimeoutInMs = prototype.getIdleConnectionTimeoutInMs();
defaultMaxConnectionPerHost = prototype.getMaxConnectionPerHost();
defaultMaxConnectionLifeTimeInMs = prototype.getMaxConnectionLifeTimeInMs();
connectionTimeOutInMs = prototype.getConnectionTimeoutInMs();
idleConnectionInPoolTimeoutInMs = prototype.getIdleConnectionInPoolTimeoutInMs();
idleConnectionTimeoutInMs = prototype.getIdleConnectionTimeoutInMs();
maxConnectionPerHost = prototype.getMaxConnectionPerHost();
maxConnectionLifeTimeInMs = prototype.getMaxConnectionLifeTimeInMs();
maxDefaultRedirects = prototype.getMaxRedirects();
defaultMaxTotalConnections = prototype.getMaxTotalConnections();
maxTotalConnections = prototype.getMaxTotalConnections();
proxyServerSelector = prototype.getProxyServerSelector();
realm = prototype.getRealm();
defaultRequestTimeoutInMs = prototype.getRequestTimeoutInMs();
requestTimeoutInMs = prototype.getRequestTimeoutInMs();
sslContext = prototype.getSSLContext();
sslEngineFactory = prototype.getSSLEngineFactory();
userAgent = prototype.getUserAgent();
......@@ -1107,14 +1108,14 @@ public class AsyncHttpClientConfig {
proxyServerSelector = ProxyServerSelector.NO_PROXY_SELECTOR;
}
return new AsyncHttpClientConfig(defaultMaxTotalConnections,
defaultMaxConnectionPerHost,
defaultConnectionTimeOutInMs,
defaultWebsocketIdleTimeoutInMs,
defaultIdleConnectionInPoolTimeoutInMs,
defaultIdleConnectionTimeoutInMs,
defaultRequestTimeoutInMs,
defaultMaxConnectionLifeTimeInMs,
return new AsyncHttpClientConfig(maxTotalConnections,
maxConnectionPerHost,
connectionTimeOutInMs,
webSocketIdleTimeoutInMs,
idleConnectionInPoolTimeoutInMs,
idleConnectionTimeoutInMs,
requestTimeoutInMs,
maxConnectionLifeTimeInMs,
redirectEnabled,
maxDefaultRedirects,
compressionEnabled,
......
......@@ -12,6 +12,8 @@
*/
package com.ning.http.client;
import static com.ning.http.client.AsyncHttpClientConfigDefaults.*;
import com.ning.http.client.filter.IOExceptionFilter;
import com.ning.http.client.filter.RequestFilter;
import com.ning.http.client.filter.ResponseFilter;
......@@ -19,7 +21,7 @@ import com.ning.http.util.ProxyUtils;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import java.util.LinkedList;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
......@@ -43,38 +45,34 @@ public class AsyncHttpClientConfigBean extends AsyncHttpClientConfig {
}
void configureDefaults() {
maxTotalConnections = Integer.getInteger(ASYNC_CLIENT + "defaultMaxTotalConnections", -1);
maxConnectionPerHost = Integer.getInteger(ASYNC_CLIENT + "defaultMaxConnectionsPerHost", -1);
connectionTimeOutInMs = Integer.getInteger(ASYNC_CLIENT + "defaultConnectionTimeoutInMS", 60 * 1000);
idleConnectionInPoolTimeoutInMs = Integer.getInteger(ASYNC_CLIENT + "defaultIdleConnectionInPoolTimeoutInMS", 60 * 1000);
idleConnectionTimeoutInMs = Integer.getInteger(ASYNC_CLIENT + "defaultIdleConnectionTimeoutInMS", 60 * 1000);
requestTimeoutInMs = Integer.getInteger(ASYNC_CLIENT + "defaultRequestTimeoutInMS", 60 * 1000);
redirectEnabled = Boolean.getBoolean(ASYNC_CLIENT + "defaultRedirectsEnabled");
maxDefaultRedirects = Integer.getInteger(ASYNC_CLIENT + "defaultMaxRedirects", 5);
compressionEnabled = Boolean.getBoolean(ASYNC_CLIENT + "compressionEnabled");
userAgent = System.getProperty(ASYNC_CLIENT + "userAgent", "NING/1.0");
ioThreadMultiplier = Integer.getInteger(ASYNC_CLIENT + "ioThreadMultiplier", 2);
boolean useProxySelector = Boolean.getBoolean(ASYNC_CLIENT + "useProxySelector");
boolean useProxyProperties = Boolean.getBoolean(ASYNC_CLIENT + "useProxyProperties");
if (useProxySelector) {
maxTotalConnections = defaultMaxTotalConnections();
maxConnectionPerHost = defaultMaxConnectionPerHost();
connectionTimeOutInMs = defaultConnectionTimeOutInMs();
webSocketIdleTimeoutInMs = defaultWebSocketIdleTimeoutInMs();
idleConnectionInPoolTimeoutInMs = defaultIdleConnectionInPoolTimeoutInMs();
idleConnectionTimeoutInMs = defaultIdleConnectionTimeoutInMs();
requestTimeoutInMs = defaultRequestTimeoutInMs();
maxConnectionLifeTimeInMs = defaultMaxConnectionLifeTimeInMs();
redirectEnabled = defaultRedirectEnabled();
maxRedirects = defaultMaxRedirects();
compressionEnabled = defaultCompressionEnabled();
userAgent = defaultUserAgent();
allowPoolingConnection = defaultAllowPoolingConnection();
useRelativeURIsWithSSLProxies = defaultUseRelativeURIsWithSSLProxies();
requestCompressionLevel = defaultRequestCompressionLevel();
maxRequestRetry = defaultMaxRequestRetry();
ioThreadMultiplier = defaultIoThreadMultiplier();
allowSslConnectionPool = defaultAllowSslConnectionPool();
useRawUrl = defaultUseRawUrl();
removeQueryParamOnRedirect = defaultRemoveQueryParamOnRedirect();
strict302Handling = defaultStrict302Handling();
hostnameVerifier = defaultHostnameVerifier();
if (defaultUseProxySelector()) {
proxyServerSelector = ProxyUtils.getJdkDefaultProxyServerSelector();
} else if (useProxyProperties) {
} else if (defaultUseProxyProperties()) {
proxyServerSelector = ProxyUtils.createProxyServerSelector(System.getProperties());
}
allowPoolingConnection = true;
requestCompressionLevel = -1;
maxRequestRetry = 5;
allowSslConnectionPool = true;
useRawUrl = false;
removeQueryParamOnRedirect = true;
hostnameVerifier = new HostnameVerifier() {
public boolean verify(String s, SSLSession sslSession) {
return true;
}
};
}
void configureExecutors() {
......@@ -107,6 +105,11 @@ public class AsyncHttpClientConfigBean extends AsyncHttpClientConfig {
return this;
}
public AsyncHttpClientConfigBean setStrict302Handling(boolean strict302Handling) {
this.strict302Handling = strict302Handling;
return this;
}
public AsyncHttpClientConfigBean setIdleConnectionTimeoutInMs(int idleConnectionTimeoutInMs) {
this.idleConnectionTimeoutInMs = idleConnectionTimeoutInMs;
return this;
......@@ -117,13 +120,18 @@ public class AsyncHttpClientConfigBean extends AsyncHttpClientConfig {
return this;
}
public AsyncHttpClientConfigBean setMaxConnectionLifeTimeInMs(int maxConnectionLifeTimeInMs) {
this.maxConnectionLifeTimeInMs = maxConnectionLifeTimeInMs;
return this;
}
public AsyncHttpClientConfigBean setRedirectEnabled(boolean redirectEnabled) {
this.redirectEnabled = redirectEnabled;
return this;
}
public AsyncHttpClientConfigBean setMaxDefaultRedirects(int maxDefaultRedirects) {
this.maxDefaultRedirects = maxDefaultRedirects;
public AsyncHttpClientConfigBean setMaxRedirects(int maxRedirects) {
this.maxRedirects = maxRedirects;
return this;
}
......
/*
* Copyright (c) 2014 AsyncHttpClient Project. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
* and you may not use this file except in compliance with the Apache License Version 2.0.
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the Apache License Version 2.0 is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
*/
package com.ning.http.client;
import com.ning.http.util.AllowAllHostnameVerifier;
import static com.ning.http.util.MiscUtil.getBoolean;
import javax.net.ssl.HostnameVerifier;
public final class AsyncHttpClientConfigDefaults {
private AsyncHttpClientConfigDefaults() {
}
public static final String ASYNC_CLIENT = AsyncHttpClientConfig.class.getName() + ".";
public static int defaultMaxTotalConnections() {
return Integer.getInteger(ASYNC_CLIENT + "maxTotalConnections", -1);
}
public static int defaultMaxConnectionPerHost() {
return Integer.getInteger(ASYNC_CLIENT + "maxConnectionsPerHost", -1);
}
public static int defaultConnectionTimeOutInMs() {
return Integer.getInteger(ASYNC_CLIENT + "connectionTimeoutInMs", 60 * 1000);
}
public static int defaultIdleConnectionInPoolTimeoutInMs() {
return Integer.getInteger(ASYNC_CLIENT + "idleConnectionInPoolTimeoutInMs", 60 * 1000);
}
public static int defaultIdleConnectionTimeoutInMs() {
return Integer.getInteger(ASYNC_CLIENT + "idleConnectionTimeoutInMs", 60 * 1000);
}
public static int defaultRequestTimeoutInMs() {
return Integer.getInteger(ASYNC_CLIENT + "requestTimeoutInMs", 60 * 1000);
}
public static int defaultWebSocketIdleTimeoutInMs() {
return Integer.getInteger(ASYNC_CLIENT + "webSocketTimoutInMS", 15 * 60 * 1000);
}
public static int defaultMaxConnectionLifeTimeInMs() {
return Integer.getInteger(ASYNC_CLIENT + "maxConnectionLifeTimeInMs", -1);
}
public static boolean defaultRedirectEnabled() {
return Boolean.getBoolean(ASYNC_CLIENT + "redirectsEnabled");
}
public static int defaultMaxRedirects() {
return Integer.getInteger(ASYNC_CLIENT + "maxRedirects", 5);
}
public static boolean defaultCompressionEnabled() {
return Boolean.getBoolean(ASYNC_CLIENT + "compressionEnabled");
}
public static String defaultUserAgent() {
return System.getProperty(ASYNC_CLIENT + "userAgent", "NING/1.0");
}
public static int defaultIoThreadMultiplier() {
return Integer.getInteger(ASYNC_CLIENT + "ioThreadMultiplier", 2);
}
public static boolean defaultUseProxySelector() {
return Boolean.getBoolean(ASYNC_CLIENT + "useProxySelector");
}
public static boolean defaultUseProxyProperties() {
return Boolean.getBoolean(ASYNC_CLIENT + "useProxyProperties");
}
public static boolean defaultStrict302Handling() {
return Boolean.getBoolean(ASYNC_CLIENT + "strict302Handling");
}
public static boolean defaultAllowPoolingConnection() {
return getBoolean(ASYNC_CLIENT + "allowPoolingConnection", true);
}
public static boolean defaultUseRelativeURIsWithSSLProxies() {
return getBoolean(ASYNC_CLIENT + "useRelativeURIsWithSSLProxies", true);
}
// unused/broken, left there for compatibility, fixed in Netty 4
public static int defaultRequestCompressionLevel() {
return Integer.getInteger(ASYNC_CLIENT + "requestCompressionLevel", -1);
}
public static int defaultMaxRequestRetry() {
return Integer.getInteger(ASYNC_CLIENT + "maxRequestRetry", 5);
}
public static boolean defaultAllowSslConnectionPool() {
return getBoolean(ASYNC_CLIENT + "allowSslConnectionPool", true);
}
public static boolean defaultUseRawUrl() {
return Boolean.getBoolean(ASYNC_CLIENT + "useRawUrl");
}
public static boolean defaultRemoveQueryParamOnRedirect() {
return getBoolean(ASYNC_CLIENT + "removeQueryParamOnRedirect", true);
}
public static HostnameVerifier defaultHostnameVerifier() {
return new AllowAllHostnameVerifier();
}
}
......@@ -31,12 +31,12 @@ public interface AsyncHttpProvider {
* @return a {@link ListenableFuture} of Type T.
* @throws IOException
*/
public <T> ListenableFuture<T> execute(Request request, AsyncHandler<T> handler) throws IOException;
<T> ListenableFuture<T> execute(Request request, AsyncHandler<T> handler) throws IOException;
/**
* Close the current underlying TCP/HTTP connection.
*/
public void close();
void close();
/**
* Prepare a {@link Response}
......@@ -46,8 +46,7 @@ public interface AsyncHttpProvider {
* @param bodyParts list of {@link HttpResponseBodyPart}
* @return a {@link Response}
*/
public Response prepareResponse(HttpResponseStatus status,
Response prepareResponse(HttpResponseStatus status,
HttpResponseHeaders headers,
List<HttpResponseBodyPart> bodyParts);
}
......@@ -29,7 +29,7 @@ public interface AsyncHttpProviderConfig<U, V> {
* @param value the value of the property
* @return this instance of AsyncHttpProviderConfig
*/
public AsyncHttpProviderConfig addProperty(U name, V value);
AsyncHttpProviderConfig addProperty(U name, V value);
/**
* Return the value associated with the property's name
......@@ -37,7 +37,7 @@ public interface AsyncHttpProviderConfig<U, V> {
* @param name
* @return this instance of AsyncHttpProviderConfig
*/
public V getProperty(U name);
V getProperty(U name);
/**
* Remove the value associated with the property's name
......@@ -45,12 +45,12 @@ public interface AsyncHttpProviderConfig<U, V> {
* @param name
* @return true if removed
*/
public V removeProperty(U name);
V removeProperty(U name);
/**
* Return the curent entry set.
*
* @return a the curent entry set.
*/
public Set<Map.Entry<U, V>> propertiesSet();
Set<Map.Entry<U, V>> propertiesSet();
}
......@@ -43,5 +43,4 @@ public interface Body {
* @throws IOException
*/
void close() throws IOException;
}
......@@ -35,5 +35,4 @@ public interface BodyConsumer {
* @throws IOException
*/
void close() throws IOException;
}
......@@ -28,7 +28,5 @@ public interface BodyGenerator {
* @return The request body, never {@code null}.
* @throws IOException If the body could not be created.
*/
Body createBody()
throws IOException;
Body createBody() throws IOException;
}
......@@ -28,7 +28,7 @@ public interface ConnectionsPool<U, V> {
* @param connection an I/O connection
* @return true if added.
*/
public boolean offer(U uri, V connection);
boolean offer(U uri, V connection);
/**
* Remove the connection associated with the uri.
......@@ -36,7 +36,7 @@ public interface ConnectionsPool<U, V> {
* @param uri the uri used when invoking addConnection
* @return the connection associated with the uri
*/
public V poll(U uri);
V poll(U uri);
/**
* Remove all connections from the cache. A connection might have been associated with several uri.
......@@ -44,7 +44,7 @@ public interface ConnectionsPool<U, V> {
* @param connection a connection
* @return the true if the connection has been removed
*/
public boolean removeAll(V connection);
boolean removeAll(V connection);
/**
* Return true if a connection can be cached. A implementation can decide based on some rules to allow caching
......@@ -52,10 +52,10 @@ public interface ConnectionsPool<U, V> {
*
* @return true if a connection can be cached.
*/
public boolean canCacheConnection();
boolean canCacheConnection();
/**
* Destroy all connections that has been cached by this instance.
*/
public void destroy();
void destroy();
}
......@@ -60,12 +60,31 @@ public class FluentCaseInsensitiveStringsMap implements Map<String, List<String>
}
}
public FluentCaseInsensitiveStringsMap add(String key, String value) {
if (key != null) {
String lcKey = key.toLowerCase(Locale.ENGLISH);
String realKey = keyLookup.get(lcKey);
List<String> curValues = null;
if (realKey == null) {
keyLookup.put(lcKey, key);
curValues = new ArrayList<String>();
values.put(key, curValues);
} else {
curValues = values.get(realKey);
}
String nonNullValue = value != null? value : "";
curValues.add(nonNullValue);
}
return this;
}
/**
* Adds the specified values and returns this object.
*
* @param key The key
* @param values The value(s); if null then this method has no effect. Use the empty string to
* generate an empty value
* @param values The value(s); if the array is null then this method has no effect. Individual null values are turned into empty strings
* @return This object
*/
public FluentCaseInsensitiveStringsMap add(String key, String... values) {
......
......@@ -54,12 +54,24 @@ public class FluentStringsMap implements Map<String, List<String>>, Iterable<Map
}
}
public FluentStringsMap add(String key, String value) {
if (key != null) {
List<String> curValues = values.get(key);
if (curValues == null) {
curValues = new ArrayList<String>(1);
values.put(key, curValues);
}
curValues.add(value);
}
return this;
}
/**
* Adds the specified values and returns this object.
*
* @param key The key
* @param values The value(s); if null then this method has no effect. Use the empty string to
* generate an empty value
* @param values The value(s); if the array is null then this method has no effect
* @return This object
*/
public FluentStringsMap add(String key, String... values) {
......@@ -73,8 +85,7 @@ public class FluentStringsMap implements Map<String, List<String>>, Iterable<Map
* Adds the specified values and returns this object.
*
* @param key The key
* @param values The value(s); if null then this method has no effect. Use an empty collection
* to generate an empty value
* @param values The value(s); if the array is null then this method has no effect
* @return This object
*/
public FluentStringsMap add(String key, Collection<String> values) {
......
......@@ -20,5 +20,5 @@ package com.ning.http.client;
* Interface for the parts in a multipart request.
*/
public interface Part {
public String getName();
String getName();
}
......@@ -44,5 +44,5 @@ public interface ProgressAsyncHandler<T> extends AsyncHandler<T> {
* @return a {@link com.ning.http.client.AsyncHandler.STATE} telling to CONTINUE or ABORT the current processing.
*/
STATE onContentWriteProgress(long amount, long current, long total);
}
......@@ -24,3 +24,4 @@ public interface ProxyServerSelector {
}
};
}
......@@ -19,8 +19,7 @@ import java.nio.channels.WritableByteChannel;
/**
* A request body which supports random access to its contents.
*/
public interface RandomAccessBody
extends Body {
public interface RandomAccessBody extends Body {
/**
* Transfers the specified chunk of bytes from this body to the specified channel.
......@@ -33,5 +32,4 @@ public interface RandomAccessBody
*/
long transferTo(long position, long count, WritableByteChannel target)
throws IOException;
}