Commit dba4dcb4 authored by Matthew Holt's avatar Matthew Holt

gzip strips Accept-Encoding header after using it

parent 7d46108c
...@@ -196,11 +196,7 @@ func (h Handler) buildEnv(r *http.Request, rule Rule) (map[string]string, error) ...@@ -196,11 +196,7 @@ func (h Handler) buildEnv(r *http.Request, rule Rule) (map[string]string, error)
for field, val := range r.Header { for field, val := range r.Header {
header := strings.ToUpper(field) header := strings.ToUpper(field)
header = headerNameReplacer.Replace(header) header = headerNameReplacer.Replace(header)
// We don't want to pass the encoding header to prevent the fastcgi server from gzipping env["HTTP_"+header] = strings.Join(val, ", ")
// TODO: is there a better way.
if header != "ACCEPT_ENCODING" {
env["HTTP_"+header] = strings.Join(val, ", ")
}
} }
return env, nil return env, nil
......
...@@ -33,6 +33,9 @@ func (g Gzip) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { ...@@ -33,6 +33,9 @@ func (g Gzip) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) {
return g.Next.ServeHTTP(w, r) return g.Next.ServeHTTP(w, r)
} }
// Delete this header so gzipping isn't repeated later in the chain
r.Header.Del("Accept-Encoding")
w.Header().Set("Content-Encoding", "gzip") w.Header().Set("Content-Encoding", "gzip")
gzipWriter := gzip.NewWriter(w) gzipWriter := gzip.NewWriter(w)
defer gzipWriter.Close() defer gzipWriter.Close()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment