hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1594805 - in /httpcomponents/httpclient/trunk/httpclient/src/main: java-deprecated/org/apache/http/impl/client/DefaultHttpClient.java java/org/apache/http/impl/client/HttpClientBuilder.java
Date Thu, 15 May 2014 07:52:13 GMT
Author: olegk
Date: Thu May 15 07:52:12 2014
New Revision: 1594805

URL: http://svn.apache.org/r1594805
Log:
HTTPCLIENT-1508: use actual JRE version when generating default User-Agent header

Modified:
    httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/client/DefaultHttpClient.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/client/DefaultHttpClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/client/DefaultHttpClient.java?rev=1594805&r1=1594804&r2=1594805&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/client/DefaultHttpClient.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/client/DefaultHttpClient.java
Thu May 15 07:52:12 2014
@@ -47,6 +47,7 @@ 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;
 
 /**
  * Default implementation of {@link org.apache.http.client.HttpClient} pre-configured
@@ -180,7 +181,8 @@ public class DefaultHttpClient extends A
         HttpProtocolParams.setContentCharset(params, HTTP.DEF_CONTENT_CHARSET.name());
         HttpConnectionParams.setTcpNoDelay(params, true);
         HttpConnectionParams.setSocketBufferSize(params, 8192);
-        HttpProtocolParams.setUserAgent(params, HttpClientBuilder.DEFAULT_USER_AGENT);
+        HttpProtocolParams.setUserAgent(params, VersionInfo.getUserAgent("Apache-HttpClient",
+                "org.apache.http.client", DefaultHttpClient.class));
     }
 
     /**

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java?rev=1594805&r1=1594804&r2=1594805&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java
Thu May 15 07:52:12 2014
@@ -35,8 +35,8 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.concurrent.TimeUnit;
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
 
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLSocketFactory;
@@ -209,15 +209,6 @@ public class HttpClientBuilder {
 
     private List<Closeable> closeables;
 
-    static final String DEFAULT_USER_AGENT;
-    static {
-        final VersionInfo vi = VersionInfo.loadVersionInfo
-                ("org.apache.http.client", HttpClientBuilder.class.getClassLoader());
-        final String release = (vi != null) ?
-                vi.getRelease() : VersionInfo.UNAVAILABLE;
-        DEFAULT_USER_AGENT = "Apache-HttpClient/" + release + " (java 1.5)";
-    }
-
     public static HttpClientBuilder create() {
         return new HttpClientBuilder();
     }
@@ -864,7 +855,8 @@ public class HttpClientBuilder {
                     userAgentCopy = System.getProperty("http.agent");
                 }
                 if (userAgentCopy == null) {
-                    userAgentCopy = DEFAULT_USER_AGENT;
+                    userAgentCopy = VersionInfo.getUserAgent("Apache-HttpClient",
+                            "org.apache.http.client", getClass());
                 }
             }
 



Mime
View raw message