mirror of
https://github.com/jetty/jetty.project.git
synced 2025-03-06 05:49:50 +00:00
400512 - ClientUpgradeRequet.addExtension() should fail if extension is not installed
This commit is contained in:
parent
e09d401fd2
commit
5c68d23138
@ -123,6 +123,15 @@ public class WebSocketClient extends ContainerLifeCycle
|
||||
request.setRequestURI(toUri);
|
||||
request.setCookiesFrom(this.cookieStore);
|
||||
|
||||
// Validate Requested Extensions
|
||||
for (ExtensionConfig reqExt : request.getExtensions())
|
||||
{
|
||||
if (!extensionRegistry.isAvailable(reqExt.getName()))
|
||||
{
|
||||
throw new IllegalArgumentException("Requested extension [" + reqExt.getName() + "] is not installed");
|
||||
}
|
||||
}
|
||||
|
||||
// Validate websocket URI
|
||||
LOG.debug("connect websocket:{} to:{}",websocket,toUri);
|
||||
|
||||
|
@ -70,6 +70,22 @@ public class WebSocketClientTest
|
||||
server.stop();
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testAddExtension_NotInstalled() throws Exception
|
||||
{
|
||||
TrackingSocket cliSock = new TrackingSocket();
|
||||
|
||||
client.getPolicy().setIdleTimeout(10000);
|
||||
|
||||
URI wsUri = server.getWsUri();
|
||||
ClientUpgradeRequest request = new ClientUpgradeRequest();
|
||||
request.setSubProtocols("echo");
|
||||
request.addExtensions("x-bad");
|
||||
|
||||
// Should trigger failure on bad extension
|
||||
client.connect(cliSock,wsUri,request);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBasicEcho_FromClient() throws Exception
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user