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

skip compression on upgrade connection #187

Merged
merged 2 commits into from
Aug 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions compress.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ func CompressHandlerLevel(h http.Handler, level int) http.Handler {
return
}

if r.Header.Get("Upgrade") != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

See the review comment.

Copy link

Choose a reason for hiding this comment

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

Which comment?

Copy link
Contributor

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.

Copy link

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.)

h.ServeHTTP(w, r)
return
}

// wrap the ResponseWriter with the writer for the chosen encoding
var encWriter io.WriteCloser
if encoding == gzipEncoding {
Expand Down