Merge remote-tracking branch 'origin/jetty-12.0.x' into fix/12.0.x/properties-update
This commit is contained in:
commit
835ec6f467
|
@ -154,15 +154,20 @@ public class SniSslConnectionFactoryTest
|
|||
{
|
||||
start((ssl, customizer) ->
|
||||
{
|
||||
// Disable the host check because this keystore has no CN and no SAN.
|
||||
// Disable the host check because this keystore has no CN and a SAN only for www.example.com.
|
||||
ssl.setKeyStorePath("src/test/resources/keystore_sni_nowild.p12");
|
||||
customizer.setSniHostCheck(false);
|
||||
});
|
||||
|
||||
// This request won't match any CN or SAN, so the "default" certificate will be returned.
|
||||
String response = getResponse("www.acme.org", null);
|
||||
assertThat(response, Matchers.containsString("X-HOST: www.acme.org"));
|
||||
assertThat(response, Matchers.containsString("X-CERT: OU=default"));
|
||||
// The JDK implementation may return aliases in random order, so the
|
||||
// "default" certificate could be any of the two present in the KeyStore.
|
||||
assertThat(response, Matchers.either(Matchers.containsString("X-CERT: OU=default"))
|
||||
.or(Matchers.containsString("X-CERT: OU=example")));
|
||||
|
||||
// This request matches a SAN in the KeyStore.
|
||||
response = getResponse("www.example.com", null);
|
||||
assertThat(response, Matchers.containsString("X-HOST: www.example.com"));
|
||||
assertThat(response, Matchers.containsString("X-CERT: OU=example"));
|
||||
|
|
|
@ -250,17 +250,6 @@ public abstract class CoreClientUpgradeRequest implements Response.CompleteListe
|
|||
int status = response.getStatus();
|
||||
String responseLine = status + " " + response.getReason();
|
||||
|
||||
if (!upgraded)
|
||||
{
|
||||
// We have failed to upgrade but have received a response, so notify the listener.
|
||||
Throwable listenerError = notifyUpgradeListeners((listener) -> listener.onHandshakeResponse(request, response));
|
||||
if (listenerError != null)
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("error from listener", listenerError);
|
||||
}
|
||||
}
|
||||
|
||||
if (result.isFailed())
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
|
@ -281,6 +270,17 @@ public abstract class CoreClientUpgradeRequest implements Response.CompleteListe
|
|||
return;
|
||||
}
|
||||
|
||||
if (!upgraded)
|
||||
{
|
||||
// We have failed to upgrade but have received a response, so notify the listener.
|
||||
Throwable listenerError = notifyUpgradeListeners((listener) -> listener.onHandshakeResponse(request, response));
|
||||
if (listenerError != null)
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("error from listener", listenerError);
|
||||
}
|
||||
}
|
||||
|
||||
if (status != HttpStatus.SWITCHING_PROTOCOLS_101)
|
||||
{
|
||||
// Failed to upgrade (other reason)
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.tests.client;
|
||||
|
||||
import java.io.EOFException;
|
||||
import java.net.URI;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
@ -22,6 +23,7 @@ import org.eclipse.jetty.client.Request;
|
|||
import org.eclipse.jetty.client.Response;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.io.Content;
|
||||
import org.eclipse.jetty.io.EofException;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
|
@ -120,4 +122,44 @@ public class ClientResponseTest
|
|||
assertThat(response.getHeaders().get("specialHeader"), equalTo("value123"));
|
||||
assertThat(content, equalTo("failed by test"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testServerAbort() throws Exception
|
||||
{
|
||||
before((req, resp, cb) ->
|
||||
{
|
||||
req.getConnectionMetaData().getConnection().getEndPoint().close();
|
||||
cb.failed(new EofException());
|
||||
return null;
|
||||
});
|
||||
|
||||
EchoSocket clientEndpoint = new EchoSocket();
|
||||
URI uri = URI.create("ws://localhost:" + _connector.getLocalPort());
|
||||
ClientUpgradeRequest upgradeRequest = new ClientUpgradeRequest();
|
||||
|
||||
CompletableFuture<Void> onHandShakeRequest = new CompletableFuture<>();
|
||||
CompletableFuture<Void> onHandShakeResponse = new CompletableFuture<>();
|
||||
JettyUpgradeListener upgradeListener = new JettyUpgradeListener()
|
||||
{
|
||||
@Override
|
||||
public void onHandshakeRequest(Request request)
|
||||
{
|
||||
onHandShakeRequest.complete(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHandshakeResponse(Request request, Response response)
|
||||
{
|
||||
onHandShakeResponse.complete(null);
|
||||
}
|
||||
};
|
||||
|
||||
Throwable t = assertThrows(Throwable.class, () ->
|
||||
_client.connect(clientEndpoint, uri, upgradeRequest, upgradeListener).get(5, TimeUnit.SECONDS));
|
||||
assertThat(t, instanceOf(ExecutionException.class));
|
||||
assertThat(t.getCause(), instanceOf(EOFException.class));
|
||||
|
||||
assertDoesNotThrow(() -> onHandShakeRequest.get(5, TimeUnit.SECONDS));
|
||||
assertThrows(Throwable.class, () -> onHandShakeResponse.get(1, TimeUnit.SECONDS));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue