mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-23 22:27:38 -05:00
Merge pull request #339 from cubicdaiya/vary-accept-encoding
gzip: added Vary: Accept-Encoding to response header.
This commit is contained in:
commit
ae2e0900c1
2 changed files with 4 additions and 0 deletions
|
@ -47,6 +47,7 @@ outer:
|
||||||
r.Header.Del("Accept-Encoding")
|
r.Header.Del("Accept-Encoding")
|
||||||
|
|
||||||
w.Header().Set("Content-Encoding", "gzip")
|
w.Header().Set("Content-Encoding", "gzip")
|
||||||
|
w.Header().Set("Vary", "Accept-Encoding")
|
||||||
gzipWriter, err := newWriter(c, w)
|
gzipWriter, err := newWriter(c, w)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// should not happen
|
// should not happen
|
||||||
|
|
|
@ -87,6 +87,9 @@ func nextFunc(shouldGzip bool) middleware.Handler {
|
||||||
if w.Header().Get("Content-Encoding") != "gzip" {
|
if w.Header().Get("Content-Encoding") != "gzip" {
|
||||||
return 0, fmt.Errorf("Content-Encoding must be gzip, found %v", r.Header.Get("Content-Encoding"))
|
return 0, fmt.Errorf("Content-Encoding must be gzip, found %v", r.Header.Get("Content-Encoding"))
|
||||||
}
|
}
|
||||||
|
if w.Header().Get("Vary") != "Accept-Encoding" {
|
||||||
|
return 0, fmt.Errorf("Vary must be Accept-Encoding, found %v", r.Header.Get("Vary"))
|
||||||
|
}
|
||||||
if _, ok := w.(gzipResponseWriter); !ok {
|
if _, ok := w.(gzipResponseWriter); !ok {
|
||||||
return 0, fmt.Errorf("ResponseWriter should be gzipResponseWriter, found %T", w)
|
return 0, fmt.Errorf("ResponseWriter should be gzipResponseWriter, found %T", w)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue