Merge pull request #4299 from eclipse/jetty-9.4.x-4248-websocketclient-success-flag
Fixes #4248 - WebSocketClient UpgradeResponse.isSuccess never set true
This commit is contained in:
commit
c44e7c5eb1
|
@ -103,7 +103,9 @@ public interface UpgradeResponse
|
|||
* or was failed (resulting in no upgrade handshake)
|
||||
*
|
||||
* @return true if upgrade response was generated, false if no upgrade response was generated
|
||||
* @deprecated this has no replacement, will be removed in Jetty 10
|
||||
*/
|
||||
@Deprecated
|
||||
boolean isSuccess();
|
||||
|
||||
/**
|
||||
|
@ -174,6 +176,8 @@ public interface UpgradeResponse
|
|||
*
|
||||
* @param success true to indicate a response to the upgrade handshake was sent, false to indicate no upgrade
|
||||
* response was sent
|
||||
* @deprecated this has no replacement, will be removed in Jetty 10
|
||||
*/
|
||||
@Deprecated
|
||||
void setSuccess(boolean success);
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -698,6 +698,8 @@ public class WebSocketServerFactory extends ContainerLifeCycle implements WebSoc
|
|||
// Process (version specific) handshake response
|
||||
handshaker.doHandshakeResponse(request, response);
|
||||
|
||||
response.setSuccess(true);
|
||||
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Websocket upgrade {} {} {} {}", request.getRequestURI(), version, response.getAcceptedSubProtocol(), wsConnection);
|
||||
|
||||
|
|
Loading…
Reference in New Issue