mirror of
https://github.com/caddyserver/caddy.git
synced 2024-11-27 19:06:26 +08:00
gzip strips Accept-Encoding header after using it
This commit is contained in:
parent
7d46108c12
commit
dba4dcb4a5
|
@ -196,12 +196,8 @@ 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, ", ")
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
|
|
Loading…
Reference in New Issue
Block a user