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

fix: websocket multi-value connection upgrades #489

Merged

Conversation

rschmukler
Copy link
Contributor

Fixes an issue where browsers could send keep-alive and Upgrade in the same request causing the ws/upgrade-request? to return false.

@weavejester
Copy link
Member

Thank you for the fix! Could you change the commit description to:

Fix websocket multi-value connection upgrades

Fix an issue where browsers could send Keep-Alive and Upgrade in the
same request causing upgrade-request? to return false.

This just makes it more consistent with the other commits in Ring.

@rschmukler
Copy link
Contributor Author

@weavejester Done! Also changed the impl to handle nil values. Sorry for the noise. Didn't run the tests locally before submitting the PR. Works now!

Copy link
Member

@weavejester weavejester left a comment

Choose a reason for hiding this comment

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

So I reviewed this a few days ago, but I forgot to submit the review, and only just noticed that my comment had "Pending" attached to it. So many apologies for the late response.

Comment on lines 69 to 75
(let [headers (:headers request)
conn-header (get headers "connection")
upgrade-header (get headers "upgrade")]
(and conn-header
upgrade-header
(re-find #"\b(?i)upgrade\b" conn-header)
(.equalsIgnoreCase "websocket" upgrade-header))))
Copy link
Member

Choose a reason for hiding this comment

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

What about:

(let [{{:strs [connection upgrade]} :headers} request]
  (and connection upgrade
       (re-find #"\b(?i)upgrade\b" connection)
       (.equalsIgnoreCase "websocket" upgrade)))

Just makes it a little neater and more concise.

@rschmukler
Copy link
Contributor Author

No problem at all! Yours looks good! I can submit an amended commit tomorrow (about 12 hours) or you're welcome to commit whatever you feel is best.

Cheers!

Fix an issue where browsers could send Keep-Alive and Upgrade in the
same request causing upgrade-request? to return false.
@rschmukler
Copy link
Contributor Author

@weavejester I've submitted a new commit with the suggested implementation. Thanks again!

@weavejester weavejester merged commit 5b44065 into ring-clojure:master Dec 7, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants