Skip to content
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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -885,11 +885,11 @@ private static boolean isContentAlwaysEmpty(HttpMethod method) {

private static boolean maybeWebSocketUpgrade(AsciiString header, CharSequence value) {
if (HttpHeaderNames.CONNECTION.contentEqualsIgnoreCase(header) &&
HttpHeaderValues.UPGRADE.contentEqualsIgnoreCase(value)) {
AsciiString.containsIgnoreCase(value, HttpHeaderValues.UPGRADE)) {
return true;
}
return HttpHeaderNames.UPGRADE.contentEqualsIgnoreCase(header) &&
HttpHeaderValues.WEBSOCKET.contentEqualsIgnoreCase(value);
AsciiString.containsIgnoreCase(value, HttpHeaderValues.WEBSOCKET);
Copy link
Contributor

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 or xxxwebsocket is a valid header value. How about splitting the value with a comma , before checking the equality?

Copy link
Member

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 and upgrade: madam-websocket?

}

private static CaseInsensitiveMap toLowercaseMap(Iterator<? extends CharSequence> valuesIter,
Expand Down
Loading