hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1525569 - in /httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main: java-deprecated/org/apache/http/impl/nio/client/DefaultHttpAsyncClient.java java/org/apache/http/impl/nio/client/HttpAsyncClientBuilder.java
Date Mon, 23 Sep 2013 12:29:16 GMT
Author: olegk
Date: Mon Sep 23 12:29:16 2013
New Revision: 1525569

URL: http://svn.apache.org/r1525569
Log:
HTTPCLIENT-1402: Cache default User-Agent value
Contributed by yuexiaojun <junedo at qq.com>

Modified:
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java-deprecated/org/apache/http/impl/nio/client/DefaultHttpAsyncClient.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/HttpAsyncClientBuilder.java

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java-deprecated/org/apache/http/impl/nio/client/DefaultHttpAsyncClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java-deprecated/org/apache/http/impl/nio/client/DefaultHttpAsyncClient.java?rev=1525569&r1=1525568&r2=1525569&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java-deprecated/org/apache/http/impl/nio/client/DefaultHttpAsyncClient.java
(original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java-deprecated/org/apache/http/impl/nio/client/DefaultHttpAsyncClient.java
Mon Sep 23 12:29:16 2013
@@ -34,7 +34,6 @@ import org.apache.http.client.protocol.R
 import org.apache.http.client.protocol.RequestProxyAuthentication;
 import org.apache.http.client.protocol.RequestTargetAuthentication;
 import org.apache.http.client.protocol.ResponseProcessCookies;
-import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.impl.nio.reactor.IOReactorConfig;
 import org.apache.http.nio.conn.ClientAsyncConnectionManager;
 import org.apache.http.nio.reactor.IOReactorException;
@@ -48,7 +47,6 @@ import org.apache.http.protocol.RequestC
 import org.apache.http.protocol.RequestExpectContinue;
 import org.apache.http.protocol.RequestTargetHost;
 import org.apache.http.protocol.RequestUserAgent;
-import org.apache.http.util.VersionInfo;
 
 @Deprecated
 public class DefaultHttpAsyncClient extends AbstractHttpAsyncClient {
@@ -77,14 +75,7 @@ public class DefaultHttpAsyncClient exte
         HttpProtocolParams.setContentCharset(params, HTTP.DEF_CONTENT_CHARSET.name());
         HttpConnectionParams.setTcpNoDelay(params, true);
         HttpConnectionParams.setSocketBufferSize(params, 8192);
-
-        // determine the release version from packaged version info
-        final VersionInfo vi = VersionInfo.loadVersionInfo
-            ("org.apache.http.nio.client", DefaultHttpClient.class.getClassLoader());
-        final String release = (vi != null) ?
-            vi.getRelease() : VersionInfo.UNAVAILABLE;
-        HttpProtocolParams.setUserAgent(params,
-                "Apache-HttpAsyncClient/" + release + " (java 1.5)");
+        HttpProtocolParams.setUserAgent(params, HttpAsyncClientBuilder.DEFAULT_USER_AGENT);
     }
 
     @Override

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/HttpAsyncClientBuilder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/HttpAsyncClientBuilder.java?rev=1525569&r1=1525568&r2=1525569&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/HttpAsyncClientBuilder.java
(original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/HttpAsyncClientBuilder.java
Mon Sep 23 12:29:16 2013
@@ -106,6 +106,14 @@ import org.apache.http.util.VersionInfo;
 @NotThreadSafe
 public class HttpAsyncClientBuilder {
 
+    final static String DEFAULT_USER_AGENT;
+    static {
+        final VersionInfo vi = VersionInfo.loadVersionInfo("org.apache.http.nio.client",
+                HttpAsyncClientBuilder.class.getClassLoader());
+        final String release = vi != null ? vi.getRelease() : VersionInfo.UNAVAILABLE;
+        DEFAULT_USER_AGENT = "Apache-HttpAsyncClient/" + release + " (java 1.5)";
+    }
+
     private NHttpClientConnectionManager connManager;
     private SchemePortResolver schemePortResolver;
     private SchemeIOSessionFactory iosessionFactory;
@@ -441,11 +449,9 @@ public class HttpAsyncClientBuilder {
             if (userAgent == null) {
                 if (systemProperties) {
                     userAgent = System.getProperty("http.agent");
-                } else {
-                    final VersionInfo vi = VersionInfo.loadVersionInfo("org.apache.http.nio.client",
-                            HttpAsyncClientBuilder.class.getClassLoader());
-                    final String release = vi != null ? vi.getRelease() : VersionInfo.UNAVAILABLE;
-                    userAgent = "Apache-HttpAsyncClient/" + release + " (java 1.5)";
+                }
+                if (userAgent == null) {
+                    userAgent = DEFAULT_USER_AGENT;
                 }
             }
 



Mime
View raw message