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

Allow access to internal ResponseWriter in gzhttp handler #799

Merged
merged 3 commits into from
Apr 5, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
add unwrap in newNoGzipResponseWriter with hijacker
  • Loading branch information
jgimenez committed Apr 3, 2023
commit b46a81d6ae5b8c30e1eeb6cd647b7fb4db5a9d22
6 changes: 6 additions & 0 deletions gzhttp/compress.go
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,10 @@ func atoi(s string) (int, bool) {
return int(i64), err == nil
}

type unwrapper interface {
Unwrap() http.ResponseWriter
}

// newNoGzipResponseWriter will return a response writer that
// cleans up compression artifacts.
// Depending on whether http.Hijacker is supported the returned will as well.
Expand All @@ -933,10 +937,12 @@ func newNoGzipResponseWriter(w http.ResponseWriter) http.ResponseWriter {
http.ResponseWriter
http.Hijacker
http.Flusher
unwrapper
}{
ResponseWriter: n,
Hijacker: hj,
Flusher: n,
unwrapper: n,
}
return x
}
Expand Down