Issue #6642 - prevent connection close after websocket upgrade
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
parent
0fc025d526
commit
f7d9d8fcf8
|
@ -345,6 +345,18 @@ public class HttpGenerator
|
|||
return Result.FLUSH;
|
||||
}
|
||||
|
||||
// If this is an upgrade then we don't want to close the connection.
|
||||
if (_info.isResponse() && ((MetaData.Response)_info).getStatus() == HttpStatus.SWITCHING_PROTOCOLS_101)
|
||||
{
|
||||
return Result.DONE;
|
||||
}
|
||||
else if (_info.isRequest())
|
||||
{
|
||||
HttpField connectionHeader = _info.getFields().getField(HttpHeader.CONNECTION);
|
||||
if (connectionHeader != null && connectionHeader.contains(HttpHeaderValue.UPGRADE.asString()))
|
||||
return Result.DONE;
|
||||
}
|
||||
|
||||
_state = State.END;
|
||||
return Boolean.TRUE.equals(_persistent) ? Result.DONE : Result.SHUTDOWN_OUT;
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ public class ConnectionHeaderTest
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"Upgrade", "keep-alive, Upgrade"}) // TODO: should we test "close, Upgrade", what should we expect?
|
||||
@ValueSource(strings = {"Upgrade", "keep-alive, Upgrade", "close, Upgrade"})
|
||||
public void testConnectionKeepAlive(String connectionHeaderValue) throws Exception
|
||||
{
|
||||
URI uri = URI.create("ws://localhost:" + connector.getLocalPort() + "/echo");
|
||||
|
|
Loading…
Reference in New Issue