Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakim Erdfelt2015-10-12 14:19:50 -0400
committerJoakim Erdfelt2015-10-12 14:19:50 -0400
commite6ffa35b2c6437519b7bce8c248cb6793f3a3144 (patch)
tree09fe54972c616984f496edc1541a2a2f8dbd01ba
parentccbd626cb2b8b691609aded7e9342116935bf8c9 (diff)
downloadorg.eclipse.jetty.project-e6ffa35b2c6437519b7bce8c248cb6793f3a3144.tar.gz
org.eclipse.jetty.project-e6ffa35b2c6437519b7bce8c248cb6793f3a3144.tar.xz
org.eclipse.jetty.project-e6ffa35b2c6437519b7bce8c248cb6793f3a3144.zip
479584 - WS Session does not contain UpgradeRequest information in WebSocketAdapter.onWebSocketConnect callback
+ Adding missing testcase + Adding missing request information
-rw-r--r--jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/UpgradeConnection.java1
-rw-r--r--jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ClientConnectTest.java20
-rw-r--r--jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/JettyTrackingSocket.java6
3 files changed, 27 insertions, 0 deletions
diff --git a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/UpgradeConnection.java b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/UpgradeConnection.java
index 310980c8e2..dbe4faee41 100644
--- a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/UpgradeConnection.java
+++ b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/UpgradeConnection.java
@@ -315,6 +315,7 @@ public class UpgradeConnection extends AbstractConnection implements Connection.
SessionFactory sessionFactory = connectPromise.getClient().getSessionFactory();
WebSocketSession session = sessionFactory.createSession(request.getRequestURI(),websocket,connection);
session.setPolicy(policy);
+ session.setUpgradeRequest(request);
session.setUpgradeResponse(response);
connection.addListener(session);
connectPromise.setSession(session);
diff --git a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ClientConnectTest.java b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ClientConnectTest.java
index 606b5b9dcf..6f4110ef51 100644
--- a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ClientConnectTest.java
+++ b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ClientConnectTest.java
@@ -19,6 +19,7 @@
package org.eclipse.jetty.websocket.client;
import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.*;
import java.io.IOException;
import java.net.ConnectException;
@@ -111,6 +112,25 @@ public class ClientConnectTest
}
@Test
+ public void testUpgradeRequest() throws Exception
+ {
+ JettyTrackingSocket wsocket = new JettyTrackingSocket();
+
+ URI wsUri = server.getWsUri();
+ Future<Session> future = client.connect(wsocket,wsUri);
+
+ IBlockheadServerConnection connection = server.accept();
+ connection.upgrade();
+
+ Session sess = future.get(500,TimeUnit.MILLISECONDS);
+
+ sess.close();
+
+ assertThat("Connect.UpgradeRequest", wsocket.connectUpgradeRequest, notNullValue());
+ assertThat("Connect.UpgradeResponse", wsocket.connectUpgradeResponse, notNullValue());
+ }
+
+ @Test
public void testBadHandshake() throws Exception
{
JettyTrackingSocket wsocket = new JettyTrackingSocket();
diff --git a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/JettyTrackingSocket.java b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/JettyTrackingSocket.java
index cbb5e59786..bb14d87be2 100644
--- a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/JettyTrackingSocket.java
+++ b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/JettyTrackingSocket.java
@@ -30,6 +30,8 @@ import org.eclipse.jetty.toolchain.test.EventQueue;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.api.Session;
+import org.eclipse.jetty.websocket.api.UpgradeRequest;
+import org.eclipse.jetty.websocket.api.UpgradeResponse;
import org.eclipse.jetty.websocket.api.WebSocketAdapter;
import org.junit.Assert;
@@ -42,6 +44,8 @@ public class JettyTrackingSocket extends WebSocketAdapter
public int closeCode = -1;
public Exchanger<String> messageExchanger;
+ public UpgradeRequest connectUpgradeRequest;
+ public UpgradeResponse connectUpgradeResponse;
public StringBuilder closeMessage = new StringBuilder();
public CountDownLatch openLatch = new CountDownLatch(1);
public CountDownLatch closeLatch = new CountDownLatch(1);
@@ -124,6 +128,8 @@ public class JettyTrackingSocket extends WebSocketAdapter
public void onWebSocketConnect(Session session)
{
super.onWebSocketConnect(session);
+ connectUpgradeRequest = session.getUpgradeRequest();
+ connectUpgradeResponse = session.getUpgradeResponse();
openLatch.countDown();
}

Back to the top