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)
for field, val := range r.Header {
header := strings.ToUpper(field)
header = headerNameReplacer.Replace(header)
// We don't want to pass the encoding header to prevent the fastcgi server from gzipping
// TODO: is there a better way.
if header != "ACCEPT_ENCODING" {
env["HTTP_"+header] = strings.Join(val, ", ")
}
env["HTTP_"+header] = strings.Join(val, ", ")
}
return env, nil
......
......@@ -33,6 +33,9 @@ func (g Gzip) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) {
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")
gzipWriter := gzip.NewWriter(w)
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