Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
</build>

<dependencies>
<dependency>
<groupId>com.typesafe</groupId>
<artifactId>config</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
*/
package org.asynchttpclient;

import static org.asynchttpclient.util.MiscUtils.getBoolean;
import org.asynchttpclient.util.AsyncPropertiesHelper;
import org.asynchttpclient.util.DefaultHostnameVerifier;

import javax.net.ssl.HostnameVerifier;

public final class AsyncHttpClientConfigDefaults {

Expand All @@ -22,106 +25,106 @@ private AsyncHttpClientConfigDefaults() {
public static final String ASYNC_CLIENT = AsyncHttpClientConfig.class.getName() + ".";

public static int defaultMaxConnections() {
return Integer.getInteger(ASYNC_CLIENT + "maxConnections", -1);
return AsyncPropertiesHelper.getAsyncHttpClientConfig().getInt(ASYNC_CLIENT + "maxConnections");
}

public static int defaultMaxConnectionsPerHost() {
return Integer.getInteger(ASYNC_CLIENT + "maxConnectionsPerHost", -1);
return AsyncPropertiesHelper.getAsyncHttpClientConfig().getInt(ASYNC_CLIENT + "maxConnectionsPerHost");
}

public static int defaultConnectionTimeout() {
return Integer.getInteger(ASYNC_CLIENT + "connectionTimeout", 60 * 1000);
return AsyncPropertiesHelper.getAsyncHttpClientConfig().getInt(ASYNC_CLIENT + "connectionTimeout");
}

public static int defaultPooledConnectionIdleTimeout() {
return Integer.getInteger(ASYNC_CLIENT + "pooledConnectionIdleTimeout", 60 * 1000);
return AsyncPropertiesHelper.getAsyncHttpClientConfig().getInt(ASYNC_CLIENT + "pooledConnectionIdleTimeout");
}

public static int defaultReadTimeout() {
return Integer.getInteger(ASYNC_CLIENT + "readTimeout", 60 * 1000);
return AsyncPropertiesHelper.getAsyncHttpClientConfig().getInt(ASYNC_CLIENT + "readTimeout");
}

public static int defaultRequestTimeout() {
return Integer.getInteger(ASYNC_CLIENT + "requestTimeout", 60 * 1000);
return AsyncPropertiesHelper.getAsyncHttpClientConfig().getInt(ASYNC_CLIENT + "requestTimeout");
}

public static int defaultWebSocketTimeout() {
return Integer.getInteger(ASYNC_CLIENT + "webSocketTimeout", 15 * 60 * 1000);
return AsyncPropertiesHelper.getAsyncHttpClientConfig().getInt(ASYNC_CLIENT + "webSocketTimeout");
}

public static int defaultConnectionTTL() {
return Integer.getInteger(ASYNC_CLIENT + "connectionTTL", -1);
return AsyncPropertiesHelper.getAsyncHttpClientConfig().getInt(ASYNC_CLIENT + "connectionTTL");
}

public static boolean defaultFollowRedirect() {
return Boolean.getBoolean(ASYNC_CLIENT + "followRedirect");
return AsyncPropertiesHelper.getAsyncHttpClientConfig().getBoolean(ASYNC_CLIENT + "followRedirect");
}

public static int defaultMaxRedirects() {
return Integer.getInteger(ASYNC_CLIENT + "maxRedirects", 5);
return AsyncPropertiesHelper.getAsyncHttpClientConfig().getInt(ASYNC_CLIENT + "maxRedirects");
}

public static boolean defaultCompressionEnforced() {
return Boolean.getBoolean(ASYNC_CLIENT + "compressionEnforced");
return AsyncPropertiesHelper.getAsyncHttpClientConfig().getBoolean(ASYNC_CLIENT + "compressionEnforced");
}

public static String defaultUserAgent() {
return System.getProperty(ASYNC_CLIENT + "userAgent", "AHC/2.0");
return AsyncPropertiesHelper.getAsyncHttpClientConfig().getString(ASYNC_CLIENT + "userAgent");
}

public static int defaultIoThreadMultiplier() {
return Integer.getInteger(ASYNC_CLIENT + "ioThreadMultiplier", 2);
return AsyncPropertiesHelper.getAsyncHttpClientConfig().getInt(ASYNC_CLIENT + "ioThreadMultiplier");
}

public static boolean defaultUseProxySelector() {
return Boolean.getBoolean(ASYNC_CLIENT + "useProxySelector");
return AsyncPropertiesHelper.getAsyncHttpClientConfig().getBoolean(ASYNC_CLIENT + "useProxySelector");
}

public static boolean defaultUseProxyProperties() {
return Boolean.getBoolean(ASYNC_CLIENT + "useProxyProperties");
return AsyncPropertiesHelper.getAsyncHttpClientConfig().getBoolean(ASYNC_CLIENT + "useProxyProperties");
}

public static boolean defaultStrict302Handling() {
return Boolean.getBoolean(ASYNC_CLIENT + "strict302Handling");
return AsyncPropertiesHelper.getAsyncHttpClientConfig().getBoolean(ASYNC_CLIENT + "strict302Handling");
}

public static boolean defaultAllowPoolingConnections() {
return getBoolean(ASYNC_CLIENT + "allowPoolingConnections", true);
return AsyncPropertiesHelper.getAsyncHttpClientConfig().getBoolean(ASYNC_CLIENT + "allowPoolingConnections");
}

public static boolean defaultUseRelativeURIsWithConnectProxies() {
return getBoolean(ASYNC_CLIENT + "useRelativeURIsWithConnectProxies", true);
}
return AsyncPropertiesHelper.getAsyncHttpClientConfig().getBoolean(ASYNC_CLIENT + "useRelativeURIsWithConnectProxies");
}

public static int defaultMaxRequestRetry() {
return Integer.getInteger(ASYNC_CLIENT + "maxRequestRetry", 5);
return AsyncPropertiesHelper.getAsyncHttpClientConfig().getInt(ASYNC_CLIENT + "maxRequestRetry");
}

public static boolean defaultAllowPoolingSslConnections() {
return getBoolean(ASYNC_CLIENT + "allowPoolingSslConnections", true);
return AsyncPropertiesHelper.getAsyncHttpClientConfig().getBoolean(ASYNC_CLIENT + "allowPoolingSslConnections");
}

public static boolean defaultDisableUrlEncodingForBoundRequests() {
return Boolean.getBoolean(ASYNC_CLIENT + "disableUrlEncodingForBoundRequests");
return AsyncPropertiesHelper.getAsyncHttpClientConfig().getBoolean(ASYNC_CLIENT + "disableUrlEncodingForBoundRequests");
}

public static boolean defaultRemoveQueryParamOnRedirect() {
return getBoolean(ASYNC_CLIENT + "removeQueryParamOnRedirect", true);
return AsyncPropertiesHelper.getAsyncHttpClientConfig().getBoolean(ASYNC_CLIENT + "removeQueryParamOnRedirect");
}

public static boolean defaultSpdyEnabled() {
return Boolean.getBoolean(ASYNC_CLIENT + "spdyEnabled");
return AsyncPropertiesHelper.getAsyncHttpClientConfig().getBoolean(ASYNC_CLIENT + "spdyEnabled");
}

public static int defaultSpdyInitialWindowSize() {
return Integer.getInteger(ASYNC_CLIENT + "spdyInitialWindowSize", 10 * 1024 * 1024);
return AsyncPropertiesHelper.getAsyncHttpClientConfig().getInt(ASYNC_CLIENT + "spdyInitialWindowSize");
}

public static int defaultSpdyMaxConcurrentStreams() {
return Integer.getInteger(ASYNC_CLIENT + "spdyMaxConcurrentStreams", 100);
return AsyncPropertiesHelper.getAsyncHttpClientConfig().getInt(ASYNC_CLIENT + "spdyMaxConcurrentStreams");
}

public static boolean defaultAcceptAnyCertificate() {
return getBoolean(ASYNC_CLIENT + "acceptAnyCertificate", false);
return AsyncPropertiesHelper.getAsyncHttpClientConfig().getBoolean(ASYNC_CLIENT + "acceptAnyCertificate");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.asynchttpclient.uri.Uri;
import org.asynchttpclient.util.AsyncHttpProviderUtils;

public enum PerHostConnectionPoolPartioning implements ConnectionPoolPartitioning {
public enum PerHostConnectionPoolPartitioning implements ConnectionPoolPartitioning {

INSTANCE;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private static final class RequestImpl implements Request {
private int requestTimeoutInMs;
private long rangeOffset;
public String charset;
private ConnectionPoolPartitioning connectionPoolPartitioning = PerHostConnectionPoolPartioning.INSTANCE;
private ConnectionPoolPartitioning connectionPoolPartitioning = PerHostConnectionPoolPartitioning.INSTANCE;
private List<Param> queryParams;

public RequestImpl() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.asynchttpclient.util;

import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;

public class AsyncPropertiesHelper {

public static final String ASYNC_HTTP_CLIENT_IMPL_PROPERTIES_FILE = "ahc.properties";
public static final String DEFAULTAHC_PROPERTIES = "ahc-default.properties";

public static Config getAsyncHttpClientConfig(){
return ConfigFactory.load(ASYNC_HTTP_CLIENT_IMPL_PROPERTIES_FILE)
.withFallback(ConfigFactory.load(DEFAULTAHC_PROPERTIES));
}

/**
* This method invalidates the property caches. So if a system property has been changed and the
* effect of this change is to be seen then call reloadProperties() and then getAsyncHttpClientConfig()
* to get the new property values.
*/
public static void reloadProperties(){
ConfigFactory.invalidateCaches();
}

}
27 changes: 27 additions & 0 deletions api/src/main/resources/ahc-default.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
org.asynchttpclient.AsyncHttpClientConfig.maxConnections=-1
org.asynchttpclient.AsyncHttpClientConfig.maxConnectionsPerHost=-1
org.asynchttpclient.AsyncHttpClientConfig.connectionTimeout=60000
org.asynchttpclient.AsyncHttpClientConfig.pooledConnectionIdleTimeout=60000
org.asynchttpclient.AsyncHttpClientConfig.readTimeout=60000
org.asynchttpclient.AsyncHttpClientConfig.requestTimeout=60000
org.asynchttpclient.AsyncHttpClientConfig.webSocketTimeout=900000
org.asynchttpclient.AsyncHttpClientConfig.connectionTTL=-1
org.asynchttpclient.AsyncHttpClientConfig.followRedirect=false
org.asynchttpclient.AsyncHttpClientConfig.maxRedirects=5
org.asynchttpclient.AsyncHttpClientConfig.compressionEnforced=false
org.asynchttpclient.AsyncHttpClientConfig.userAgent=NING/1.0
org.asynchttpclient.AsyncHttpClientConfig.ioThreadMultiplier=2
org.asynchttpclient.AsyncHttpClientConfig.useProxySelector=false
org.asynchttpclient.AsyncHttpClientConfig.useProxyProperties=false
org.asynchttpclient.AsyncHttpClientConfig.strict302Handling=false
org.asynchttpclient.AsyncHttpClientConfig.allowPoolingConnections=true
org.asynchttpclient.AsyncHttpClientConfig.useRelativeURIsWithConnectProxies=true
org.asynchttpclient.AsyncHttpClientConfig.requestCompressionLevel=-1
org.asynchttpclient.AsyncHttpClientConfig.maxRequestRetry=5
org.asynchttpclient.AsyncHttpClientConfig.allowPoolingSslConnections=true
org.asynchttpclient.AsyncHttpClientConfig.disableUrlEncodingForBoundRequests=false
org.asynchttpclient.AsyncHttpClientConfig.removeQueryParamOnRedirect=true
org.asynchttpclient.AsyncHttpClientConfig.spdyEnabled=false
org.asynchttpclient.AsyncHttpClientConfig.spdyInitialWindowSize=10485760
org.asynchttpclient.AsyncHttpClientConfig.spdyMaxConcurrentStreams=100
org.asynchttpclient.AsyncHttpClientConfig.acceptAnyCertificate=false
Loading