cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1370736 - in /cxf/branches/2.5.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java
Date Wed, 08 Aug 2012 10:38:55 GMT
Author: sergeyb
Date: Wed Aug  8 10:38:54 2012
New Revision: 1370736

URL: http://svn.apache.org/viewvc?rev=1370736&view=rev
Log:
Merged revisions 1370721 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/branches/2.6.x-fixes

................
  r1370721 | sergeyb | 2012-08-08 12:48:21 +0300 (Wed, 08 Aug 2012) | 9 lines
  
  Merged revisions 1370720 via svnmerge from 
  https://svn.apache.org/repos/asf/cxf/trunk
  
  ........
    r1370720 | sergeyb | 2012-08-08 12:44:31 +0300 (Wed, 08 Aug 2012) | 1 line
    
    Trying to calculate a correct base address in cases where the scheme is not http-based,
as in Camel servlet
  ........
................

Modified:
    cxf/branches/2.5.x-fixes/   (props changed)
    cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java

Propchange: cxf/branches/2.5.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Wed Aug  8 10:38:54 2012
@@ -0,0 +1,2 @@
+/cxf/branches/2.6.x-fixes:1370721
+/cxf/trunk:1370720

Propchange: cxf/branches/2.5.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java?rev=1370736&r1=1370735&r2=1370736&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java
Wed Aug  8 10:38:54 2012
@@ -50,6 +50,7 @@ import org.apache.cxf.message.Message;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.transport.Destination;
 import org.apache.cxf.transport.http.AbstractHTTPDestination;
+import org.apache.cxf.transport.servlet.BaseUrlHelper;
 
 public final class HttpUtils {
     
@@ -59,6 +60,7 @@ public final class HttpUtils {
     private static final String REQUEST_PATH_TO_MATCH = "path_to_match";
     private static final String REQUEST_PATH_TO_MATCH_SLASH = "path_to_match_slash";
     
+    private static final String HTTP_SCHEME = "http";
     private static final String ANY_IP_ADDRESS = "0.0.0.0";
     private static final String ANY_IP_ADDRESS_START = "://0.0.0.0";
     private static final int DEFAULT_HTTP_PORT = 80;
@@ -186,6 +188,16 @@ public final class HttpUtils {
                || HttpHeaders.LAST_MODIFIED.equalsIgnoreCase(headerName); 
     }
     
+    public static boolean isHttpRequest(Message message) {
+        return message.get(AbstractHTTPDestination.HTTP_REQUEST) != null;
+    }
+    
+    public static URI toAbsoluteUri(String relativePath, Message message) {
+        String base = BaseUrlHelper.getBaseURL(
+            (HttpServletRequest)message.get(AbstractHTTPDestination.HTTP_REQUEST));
+        return URI.create(base + relativePath);
+    }
+    
     public static URI toAbsoluteUri(URI u, Message message) {
         HttpServletRequest request = 
             (HttpServletRequest)message.get(AbstractHTTPDestination.HTTP_REQUEST);
@@ -240,7 +252,13 @@ public final class HttpUtils {
     public static String getBaseAddress(Message m) {
         String endpointAddress = getEndpointAddress(m);
         try {
-            String path = new URI(endpointAddress).getRawPath();
+            URI uri = new URI(endpointAddress);
+            String path = uri.getRawPath();
+            String scheme = uri.getScheme();
+            if (scheme != null && !scheme.startsWith(HttpUtils.HTTP_SCHEME)
+                && HttpUtils.isHttpRequest(m)) {
+                path = HttpUtils.toAbsoluteUri(path, m).getRawPath();
+            }
             return path.length() == 0 ? "/" : path;
         } catch (URISyntaxException ex) {
             return endpointAddress == null ? "/" : endpointAddress;



Mime
View raw message