8240666: Websocket client’s OpeningHandshake discards the HTTP response body
The fix updates jdk.internal.net.http.websocket. OpeningHandshake.send() method to process the response body from server Reviewed-by: chegar, dfuchs, prappo
This commit is contained in:
parent
9f86d94580
commit
ed24927500
@ -188,7 +188,7 @@ public class OpeningHandshake {
|
||||
|
||||
public CompletableFuture<Result> send() {
|
||||
PrivilegedAction<CompletableFuture<Result>> pa = () ->
|
||||
client.sendAsync(this.request, BodyHandlers.discarding())
|
||||
client.sendAsync(this.request, BodyHandlers.ofString())
|
||||
.thenCompose(this::resultFrom);
|
||||
return AccessController.doPrivileged(pa);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -23,6 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8240666
|
||||
* @summary Basic test for WebSocketHandshakeException
|
||||
* @library /test/lib
|
||||
* @build jdk.test.lib.net.SimpleSSLContext
|
||||
@ -55,7 +56,9 @@ import java.util.concurrent.Executors;
|
||||
import static java.net.http.HttpClient.Builder.NO_PROXY;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.Assert.fail;
|
||||
import static java.lang.System.out;
|
||||
|
||||
public class WSHandshakeExceptionTest {
|
||||
|
||||
@ -107,6 +110,9 @@ public class WSHandshakeExceptionTest {
|
||||
}
|
||||
WebSocketHandshakeException wse = (WebSocketHandshakeException) t;
|
||||
assertNotNull(wse.getResponse());
|
||||
out.println("Status code is " + wse.getResponse().statusCode());
|
||||
out.println("Response is " + wse.getResponse().body());
|
||||
assertTrue(((String)wse.getResponse().body()).contains("404"));
|
||||
assertEquals(wse.getResponse().statusCode(), 404);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user