-
Notifications
You must be signed in to change notification settings - Fork 923
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
feat: Fix maybeWebSocketUpgrade
to return true when Connection/Upgrade header has multiple…
#5958
base: main
Are you sure you want to change the base?
Changes from 5 commits
eaa91e1
3b21593
0e3b66b
82fe92a
02b2074
46e8ad7
b544f41
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,7 +102,9 @@ void http1Handshake(SessionProtocol sessionProtocol, boolean useThreadRescheduli | |
.build(); | ||
final RequestHeadersBuilder headersBuilder = | ||
RequestHeaders.builder(HttpMethod.GET, "/chat") | ||
.add(HttpHeaderNames.CONNECTION, HttpHeaderValues.UPGRADE.toString()); | ||
// It works even if the header contains multiple values | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question) When I checked, it seems like this test passes with the main branch without the changes in this PR. I'm curious, were you able to verify the same bug with the HEAD of the main branch? It seems a little odd since There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, @jrhee17. In |
||
.add(HttpHeaderNames.CONNECTION, HttpHeaderValues.UPGRADE + | ||
", " + HttpHeaderValues.KEEP_ALIVE); | ||
final Channel channel; | ||
try (ClientRequestContextCaptor captor = Clients.newContextCaptor()) { | ||
final AggregatedHttpResponse res = client.execute(headersBuilder.build()).aggregate().join(); | ||
|
@@ -114,7 +116,7 @@ void http1Handshake(SessionProtocol sessionProtocol, boolean useThreadRescheduli | |
"Connection: Upgrade"); | ||
} | ||
|
||
headersBuilder.add(HttpHeaderNames.UPGRADE, HttpHeaderValues.WEBSOCKET.toString()); | ||
headersBuilder.add(HttpHeaderNames.UPGRADE, HttpHeaderValues.WEBSOCKET + ", additional_value"); | ||
try (ClientRequestContextCaptor captor = Clients.newContextCaptor()) { | ||
final AggregatedHttpResponse res = client.execute(headersBuilder.build()).aggregate().join(); | ||
|
||
|
@@ -192,7 +194,10 @@ void http2Handshake(SessionProtocol sessionProtocol) { | |
|
||
final RequestHeadersBuilder headersBuilder = | ||
RequestHeaders.builder(HttpMethod.CONNECT, "/chat") | ||
.add(HttpHeaderNames.PROTOCOL, HttpHeaderValues.WEBSOCKET.toString()); | ||
.add(HttpHeaderNames.PROTOCOL, HttpHeaderValues.WEBSOCKET.toString()) | ||
// It works even if the header contains multiple values | ||
.add(HttpHeaderNames.CONNECTION, HttpHeaderValues.KEEP_ALIVE.toString()) | ||
.add(HttpHeaderNames.UPGRADE, "additional_value"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's revert this change. I realized that HTTP/2 uses the different method so we probably don't need to check for HTTP/2. |
||
SplitHttpResponse split = client.execute(headersBuilder.build()).split(); | ||
ResponseHeaders responseHeaders = split.headers().join(); | ||
split.body().abort(); | ||
|
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 don't think either
websocketxxx
orxxxwebsocket
is a valid header value. How about splitting the value with a comma,
before checking the equality?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.
Can we also add a test case that makes sure it doesn't pick up headers like
connection: not-upgrade-lol
andupgrade: madam-websocket
?