mirror of
https://github.com/caddyserver/caddy.git
synced 2025-02-14 04:22:28 +03:00
gzip: Fix Content-Length header for proxies requests (closes #38)
This commit is contained in:
parent
9df9ad975d
commit
ca95b561dc
1 changed files with 9 additions and 0 deletions
|
@ -64,6 +64,15 @@ type gzipResponseWriter struct {
|
||||||
http.ResponseWriter
|
http.ResponseWriter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WriteHeader wraps the underlying WriteHeader method to prevent
|
||||||
|
// problems with conflicting headers from proxied backends. For
|
||||||
|
// example, a backend system that calculates Content-Length would
|
||||||
|
// be wrong because it doesn't know it's being gzipped.
|
||||||
|
func (w gzipResponseWriter) WriteHeader(code int) {
|
||||||
|
w.Header().Del("Content-Length")
|
||||||
|
w.ResponseWriter.WriteHeader(code)
|
||||||
|
}
|
||||||
|
|
||||||
// Write wraps the underlying Write method to do compression.
|
// Write wraps the underlying Write method to do compression.
|
||||||
func (w gzipResponseWriter) Write(b []byte) (int, error) {
|
func (w gzipResponseWriter) Write(b []byte) (int, error) {
|
||||||
if w.Header().Get("Content-Type") == "" {
|
if w.Header().Get("Content-Type") == "" {
|
||||||
|
|
Loading…
Reference in a new issue