-
Notifications
You must be signed in to change notification settings - Fork 1.9k
PR #12659 - allow HttpVersion to be set on WebSocket ClientUpgradeRequest #13185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: jetty-12.1.x
Are you sure you want to change the base?
PR #12659 - allow HttpVersion to be set on WebSocket ClientUpgradeRequest #13185
Conversation
…Request Signed-off-by: Lachlan Roberts <[email protected]>
/** | ||
* Set the HTTP Version to use for the websocket upgrade. | ||
* <p> | ||
* Currently only HTTP/1.1 (with RFC6455) and HTTP/2 (with RFC8441) are supported. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would avoid specifying this, as when we implement it for HTTP/3 we will forget about this javadoc.
String scheme = uri.getScheme(); | ||
if (!HttpScheme.WS.is(scheme) && !HttpScheme.WSS.is(scheme)) | ||
throw new IllegalArgumentException("URI scheme must be 'ws' or 'wss'"); | ||
this.host = this.requestURI.getHost(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This removal feels wrong, as WebSocketClient.connect(endPoint, URI, ClientUpgradeRequest)
should have been deprecated instead.
I would have kept WebSocketClient.connect(endPoint, URI)
, but when I pass ClientUpgradeRequest
, then everything is configured in it, rather than the URI separated from ClientUpgradeRequest
, so just have
WebSocketClient.connect(endPoint, ClientUpgradeRequest)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw this constructor had been deprecated for ages so I removed it.
Otherwise it is not really related to this PR, so reverting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened issue #13213 for this
public String getHttpVersion() | ||
{ | ||
throw new UnsupportedOperationException("HttpVersion not available on ClientUpgradeRequest"); | ||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's now very weird that we cannot get the URI host (and other things) from a request.
assertThat(wsEndPoint.closeReason, equalTo("normal close from test")); | ||
|
||
// Wait for the request to complete on server before stopping. | ||
assertTrue(latch.await(5, TimeUnit.SECONDS)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are not sure that the upgrade actually happened with HTTP/2.
Can you modify TestJettyWebSocketServlet
to have a /ws/version
endpoint that returns the HTTP version as seen by the server, and then you assert that in the test?
Signed-off-by: Lachlan Roberts <[email protected]>
closes #12659
Implement
setHttpVersion
method onClientUpgradeRequest
so thatWebSocketClients
supporting both HTTP/1.1 and HTTP/2 websocket upgrades can select which one to use.