cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-6869] Updating UserAgent as suggested by Colin Hurley
Date Tue, 26 Apr 2016 10:37:58 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes c8636c036 -> bbba1ad5e


[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/bbba1ad5
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/bbba1ad5
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/bbba1ad5

Branch: refs/heads/3.1.x-fixes
Commit: bbba1ad5ec756a273c9c57eeb4bc2c9e66b82326
Parents: c8636c0
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Tue Apr 19 12:00:27 2016 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Tue Apr 26 11:37:32 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/bbba1ad5/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 a57561b..51d156b 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