-
Notifications
You must be signed in to change notification settings - Fork 272
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
skip compression on upgrade connection #187
skip compression on upgrade connection #187
Conversation
This issue has been automatically marked as stale because it hasn't seen a recent update. It'll be automatically closed in a few days. |
bump |
compress.go
Outdated
var upgrade bool | ||
for _, v := range strings.Split(r.Header.Get("Connection"), ",") { | ||
if strings.ToLower(strings.TrimSpace(v)) == "upgrade" { | ||
upgrade = true | ||
break | ||
} | ||
} | ||
if upgrade { | ||
h.ServeHTTP(w, r) | ||
return | ||
} |
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.
This should be sufficient:
var upgrade bool | |
for _, v := range strings.Split(r.Header.Get("Connection"), ",") { | |
if strings.ToLower(strings.TrimSpace(v)) == "upgrade" { | |
upgrade = true | |
break | |
} | |
} | |
if upgrade { | |
h.ServeHTTP(w, r) | |
return | |
} | |
if r.Header.Get("Upgrade") != "" { | |
h.ServeHTTP(w, r) | |
return | |
} |
@@ -102,6 +102,11 @@ func CompressHandlerLevel(h http.Handler, level int) http.Handler { | |||
return | |||
} | |||
|
|||
if r.Header.Get("Upgrade") != "" { |
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.
See the review comment.
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.
Which comment?
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.
#187 (comment) - maybe I misunderstood here.
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.
Ah! The proposal I made was already pushed, these 4 lines checking the Upgrade
header should work fine (I've been using a wrapper implementing exactly this in production on framer.com for many months and haven't run into any issues with WebSockets.)
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.
Thanks @blixt!
Fixes #182
Summary of Changes