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

Better handling of websocket headers #143

Merged
merged 1 commit into from
Jul 12, 2018
Merged

Conversation

krasnoukhov
Copy link
Contributor

The problem is that Firefox sends a following header:

Connection: keep-alive, Upgrade

Which isn't parsed correctly by puma-dev right now, but it seems to be valid according to MDN docs.

Here's how websocket-driver parses it, but I think checking the suffix will be enough:

https://github.com/faye/websocket-driver-ruby/blob/ec94a219e91a0cf7968c076e67060c48d458b257/lib/websocket/driver.rb#L228

This closes #48

@RoM4iK
Copy link

RoM4iK commented Dec 22, 2017

@evanphx can you review, please?

@@ -179,7 +179,7 @@ func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
outreq.Header.Set("X-Forwarded-Proto", "http")
}

if req.Header.Get("Connection") == "Upgrade" &&
if strings.HasSuffix(req.Header.Get("Connection"), "Upgrade") &&

Choose a reason for hiding this comment

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

Firefox says it's a comma separated list of headers. I can't tell if that's part of the standard or not? If so, it would probably be better to split on a comma. Otherwise, I think it would be better to do a Contains instead of a HasSuffix since those headers shouldn't be required to be positional.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. Changed to Contains

@joallard
Copy link

Awesome @evanphx! Do you have an estimate as to a release?

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.

Web sockets on 0.8 release
5 participants