cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject [03/21] cxf git commit: [CXF-6869] Updating UserAgent as suggested by Colin Hurley
Date Fri, 22 Apr 2016 02:13:11 GMT
[CXF-6869] Updating UserAgent as suggested by Colin Hurley


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/a9d90452
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/a9d90452
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/a9d90452

Branch: refs/heads/master-jaxrs-2.1
Commit: a9d90452dc9a21e39ba9869c68d219c4e81c9f2b
Parents: 66606fe
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Tue Apr 19 12:00:27 2016 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Tue Apr 19 12:00:27 2016 +0100

----------------------------------------------------------------------
 .../org/apache/cxf/transport/http/Headers.java    | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/a9d90452/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Headers.java
----------------------------------------------------------------------
diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Headers.java b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Headers.java
index ad0d8c1..637da3f 100644
--- a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Headers.java
+++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Headers.java
@@ -75,11 +75,12 @@ public class Headers {
      * Known HTTP headers whose values have to be represented as individual HTTP headers
      */
     private static final Set<String> HTTP_HEADERS_SINGLE_VALUE_ONLY;
-    
+    private static final String USER_AGENT;
     static {
         HTTP_HEADERS_SINGLE_VALUE_ONLY = new HashSet<String>();
         HTTP_HEADERS_SINGLE_VALUE_ONLY.add(HTTP_HEADERS_SETCOOKIE);
         HTTP_HEADERS_SINGLE_VALUE_ONLY.add(HTTP_HEADERS_LINK);
+        USER_AGENT = initUserAgent();
     }
     
     private final Message message;
@@ -94,6 +95,19 @@ public class Headers {
         this.message = null;
     }
     
+    public static String getUserAgent() {
+        return USER_AGENT;
+    }
+    
+    private static String initUserAgent() {
+        String name = Version.getName();
+        if ("Apache CXF".equals(name)) {
+            name = "Apache-CXF";
+        }
+        String version = Version.getCurrentVersion();
+        return name + "/" + version;
+    }
+    
     public Map<String, List<String>> headerMap() {
         return headers;
     }
@@ -387,7 +401,7 @@ public class Headers {
         }
         // make sure we don't add more than one User-Agent header
         if (connection.getRequestProperty("User-Agent") == null) {
-            connection.addRequestProperty("User-Agent", Version.getCompleteVersionString());
+            connection.addRequestProperty("User-Agent", USER_AGENT);
         }
     }
     


Mime
View raw message