cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [1/4] cxf git commit: When not using Atmosphere, make sure the Upgrade headers are copied into the other headers so auth info is passed
Date Fri, 18 Aug 2017 20:28:06 GMT
Repository: cxf
Updated Branches:
  refs/heads/master bd0408ca9 -> 332cd6e96


When not using Atmosphere, make sure the Upgrade headers are copied into the other headers
so auth info is passed


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

Branch: refs/heads/master
Commit: 332cd6e96b04d6d2ae077e2074b10b6b4163f235
Parents: 8592c87
Author: Daniel Kulp <dkulp@apache.org>
Authored: Fri Aug 18 15:28:07 2017 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Fri Aug 18 15:28:36 2017 -0400

----------------------------------------------------------------------
 .../websocket/jetty/WebSocketVirtualServletRequest.java   | 10 +++++++++-
 .../websocket/jetty9/Jetty9WebSocketDestination.java      |  7 ++++---
 .../jaxws/websocket/ClientServerWebSocketTest.java        |  1 +
 3 files changed, 14 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/332cd6e9/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/WebSocketVirtualServletRequest.java
----------------------------------------------------------------------
diff --git a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/WebSocketVirtualServletRequest.java
b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/WebSocketVirtualServletRequest.java
index a5906d7..e511c3e 100644
--- a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/WebSocketVirtualServletRequest.java
+++ b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/WebSocketVirtualServletRequest.java
@@ -29,6 +29,7 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Enumeration;
+import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import java.util.TreeMap;
@@ -54,6 +55,7 @@ import javax.servlet.http.Part;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.transport.websocket.InvalidPathException;
 import org.apache.cxf.transport.websocket.WebSocketUtils;
+import org.eclipse.jetty.websocket.api.Session;
 
 /**
  *
@@ -66,12 +68,18 @@ public class WebSocketVirtualServletRequest implements HttpServletRequest
{
     private Map<String, String> requestHeaders;
     private Map<String, Object> attributes;
 
-    public WebSocketVirtualServletRequest(WebSocketServletHolder websocket, InputStream in)
+    public WebSocketVirtualServletRequest(WebSocketServletHolder websocket, InputStream in,
Session session)
         throws IOException {
         this.webSocketHolder = websocket;
         this.in = in;
 
+        Map<String, List<String>> ugHeaders = session.getUpgradeRequest().getHeaders();
         this.requestHeaders = WebSocketUtils.readHeaders(in);
+        for (Map.Entry<String, List<String>> ent : ugHeaders.entrySet()) {
+            if (!requestHeaders.containsKey(ent.getKey())) {
+                requestHeaders.put(ent.getKey(), ent.getValue().get(0));
+            }
+        }
         String path = requestHeaders.get(WebSocketUtils.URI_KEY);
         String origin = websocket.getRequestURI();
         if (!path.startsWith(origin)) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/332cd6e9/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty9/Jetty9WebSocketDestination.java
----------------------------------------------------------------------
diff --git a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty9/Jetty9WebSocketDestination.java
b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty9/Jetty9WebSocketDestination.java
index 5cad28c..6bae8b1 100644
--- a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty9/Jetty9WebSocketDestination.java
+++ b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty9/Jetty9WebSocketDestination.java
@@ -182,7 +182,7 @@ public class Jetty9WebSocketDestination extends JettyHTTPDestination implements
                 try {
                     WebSocketServletHolder holder = new Jetty9WebSocketHolder(session);
                     response = createServletResponse(holder);
-                    request = createServletRequest(data, offset, length, holder);
+                    request = createServletRequest(data, offset, length, holder, session);
                     String reqid = request.getHeader(REQUEST_ID_KEY);
                     if (reqid != null) {
                         response.setHeader(RESPONSE_ID_KEY, reqid);
@@ -219,9 +219,10 @@ public class Jetty9WebSocketDestination extends JettyHTTPDestination
implements
         }
     }
     private WebSocketVirtualServletRequest createServletRequest(byte[] data, int offset,
int length,
-                                                                WebSocketServletHolder holder)
+                                                                WebSocketServletHolder holder,
+                                                                Session session)
         throws IOException {
-        return new WebSocketVirtualServletRequest(holder, new ByteArrayInputStream(data,
offset, length));
+        return new WebSocketVirtualServletRequest(holder, new ByteArrayInputStream(data,
offset, length), session);
     }
 
     private WebSocketVirtualServletResponse createServletResponse(WebSocketServletHolder
holder) throws IOException {

http://git-wip-us.apache.org/repos/asf/cxf/blob/332cd6e9/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/websocket/ClientServerWebSocketTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/websocket/ClientServerWebSocketTest.java
b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/websocket/ClientServerWebSocketTest.java
index 0e6d715..75ebaf6 100644
--- a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/websocket/ClientServerWebSocketTest.java
+++ b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/websocket/ClientServerWebSocketTest.java
@@ -61,6 +61,7 @@ public class ClientServerWebSocketTest extends AbstractBusClientServerTestBase
{
     @BeforeClass
     public static void startServers() throws Exception {
         // set up configuration to enable schema validation
+        //System.setProperty("org.apache.cxf.transport.websocket.atmosphere.disabled", "true");
         assertTrue("server did not launch correctly", launchServer(Server.class, true));
         createStaticBus();
     }


Mime
View raw message