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

Issue #12429 - case-insensitive headers for websocket #12441

Merged

Conversation

lachlan-roberts
Copy link
Contributor

Issue #12429

Add a new static method HttpFields.asMap(HttpFields fields) and use it everywhere in WebSocket where the HttpFields are converted into a Map<String, List<String>> so that the headers in the map are treated as case-insensitive.

@lachlan-roberts
Copy link
Contributor Author

@gregw @joakime I have changed it so that the HttpFields.asMap decides if the map is modifiable or not. If it is not modifiable it will wrap the HttpFields instead of being backed by a TreeMap, so that any modification to the map is also made to the HttpFields.

I have also reviewed the error handling for the WebSocketCreators, which I found to be incorrect in some places.

Copy link
Contributor

@gregw gregw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, but a few niggles

Copy link
Contributor

@gregw gregw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, but I do think one method is best.

Signed-off-by: Lachlan Roberts <[email protected]>
gregw
gregw previously approved these changes Nov 1, 2024
@sbordet sbordet linked an issue Nov 3, 2024 that may be closed by this pull request
Signed-off-by: Lachlan Roberts <[email protected]>
Copy link
Contributor

@sbordet sbordet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I replied to your comments.

Signed-off-by: Lachlan Roberts <[email protected]>
cb.failed(t);
if (LOG.isDebugEnabled())
LOG.debug("Could not create WebSocket endpoint", t);
Response.writeError(req, resp, cb, HttpStatus.INTERNAL_SERVER_ERROR_500, "Could not create WebSocket endpoint");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check whether cb.failed() is enough, because the javadocs of creator.createWebSocket() say to use JettyServerUpgradeResponse. sendError().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think cb.failed() is probably better. This will result in the JettyWebSocketServerContainer#upgrade throwing, which can be caught and handled by their application, or if its not caught will result in a sendError() anyway.

Signed-off-by: Lachlan Roberts <[email protected]>
@lachlan-roberts lachlan-roberts merged commit b57b8e6 into jetty-12.0.x Nov 12, 2024
10 checks passed
@lachlan-roberts lachlan-roberts deleted the jetty-12.0.x-12429-caseInsensitiveHeadersWebSocket branch November 12, 2024 03:58
lachlan-roberts added a commit that referenced this pull request Nov 12, 2024
Signed-off-by: Lachlan Roberts <[email protected]>
lachlan-roberts added a commit that referenced this pull request Nov 12, 2024
Signed-off-by: Lachlan Roberts <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

HandshakeRequest getHeaders are case sensitive.
4 participants