ADDITIONAL SYSTEM INFORMATION :
Tested with 11, but the code is same in 14 too.
A DESCRIPTION OF THE PROBLEM :
`jdk.internal.net.http.websocket.OpeningHandshake#send` passes a `BodyHandlers.discarding()` as `BodyHandler` which does make sense for a successful HTTP upgrade. However, when the server rejects the HTTP upgrade (e.g. 401 'Unauthorized'), it may want to share details about the nature of the problem in the response body. I read through RFC of Websocket (https://tools.ietf.org/html/rfc6455) but did not find explicitly that returning a response body from serverside must not be done. I might be missing something, but discarding the response body is an unnecessary limitation.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a Websocket server implementation so that it rejects HTTP upgrade.
Fill the response body on server side
Try establishing connection to the server.
From the caught `CompletionException` extract the response body: `((WebSocketHandshakeException) e.getCause()).getResponse().body()`
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The response body defined on server side
ACTUAL -
`null`
FREQUENCY : always
Tested with 11, but the code is same in 14 too.
A DESCRIPTION OF THE PROBLEM :
`jdk.internal.net.http.websocket.OpeningHandshake#send` passes a `BodyHandlers.discarding()` as `BodyHandler` which does make sense for a successful HTTP upgrade. However, when the server rejects the HTTP upgrade (e.g. 401 'Unauthorized'), it may want to share details about the nature of the problem in the response body. I read through RFC of Websocket (https://tools.ietf.org/html/rfc6455) but did not find explicitly that returning a response body from serverside must not be done. I might be missing something, but discarding the response body is an unnecessary limitation.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a Websocket server implementation so that it rejects HTTP upgrade.
Fill the response body on server side
Try establishing connection to the server.
From the caught `CompletionException` extract the response body: `((WebSocketHandshakeException) e.getCause()).getResponse().body()`
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The response body defined on server side
ACTUAL -
`null`
FREQUENCY : always
- relates to
-
JDK-8244652 Add test for non utf-8 response handling by websocket client
-
- Resolved
-