Fixes #4248 - WebSocketClient UpgradeResponse.isSuccess never set true

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
This commit is contained in:
Joakim Erdfelt 2019-11-12 10:14:51 -06:00
parent 4825832a53
commit 544ad0a28a
No known key found for this signature in database
GPG Key ID: 2D0E1FB8FE4B68B4
3 changed files with 13 additions and 3 deletions

View File

@ -55,6 +55,13 @@ public class ClientUpgradeResponse extends UpgradeResponseAdapter
setAcceptedSubProtocol(fields.get(HttpHeader.SEC_WEBSOCKET_SUBPROTOCOL));
}
@Override
public boolean isSuccess()
{
// If we reached this point, where we have a UpgradeResponse object, then the upgrade is a success.
return true;
}
@Override
public List<ExtensionConfig> getExtensions()
{

View File

@ -596,9 +596,11 @@ public class WebSocketUpgradeRequest extends HttpRequest implements CompleteList
URI requestURI = this.getURI();
ClientUpgradeResponse upgradeResponse = new ClientUpgradeResponse(response);
WebSocketSession session = getSessionFactory().createSession(requestURI, localEndpoint, connection);
session.setUpgradeRequest(new ClientUpgradeRequest(this));
session.setUpgradeResponse(new ClientUpgradeResponse(response));
session.setUpgradeResponse(upgradeResponse);
connection.addListener(session);
List<ExtensionConfig> extensions = new ArrayList<>();
@ -637,7 +639,7 @@ public class WebSocketUpgradeRequest extends HttpRequest implements CompleteList
if (upgradeListener != null)
{
upgradeListener.onHandshakeResponse(new ClientUpgradeResponse(response));
upgradeListener.onHandshakeResponse(upgradeResponse);
}
// Now swap out the connection

View File

@ -196,7 +196,8 @@ public class CookieTest
serverConn.write(serverCookieFrame);
// Confirm client connect on future
clientConnectFuture.get(10, TimeUnit.SECONDS);
Session session = clientConnectFuture.get(10, TimeUnit.SECONDS);
assertTrue(session.getUpgradeResponse().isSuccess(), "UpgradeResponse.isSuccess()");
clientSocket.awaitOpen(2, TimeUnit.SECONDS);
// Wait for client receipt of cookie frame via client websocket