mirror of
https://github.com/caddyserver/caddy.git
synced 2024-11-29 04:10:16 +08:00
gzip,mime: show response header instead of the request one in test message
This commit is contained in:
parent
a6ec51b349
commit
387a083255
|
@ -109,10 +109,10 @@ func nextFunc(shouldGzip bool) httpserver.Handler {
|
||||||
|
|
||||||
if shouldGzip {
|
if shouldGzip {
|
||||||
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", w.Header().Get("Content-Encoding"))
|
||||||
}
|
}
|
||||||
if w.Header().Get("Vary") != "Accept-Encoding" {
|
if w.Header().Get("Vary") != "Accept-Encoding" {
|
||||||
return 0, fmt.Errorf("Vary must be Accept-Encoding, found %v", r.Header.Get("Vary"))
|
return 0, fmt.Errorf("Vary must be Accept-Encoding, found %v", w.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)
|
||||||
|
|
|
@ -57,7 +57,7 @@ func nextFunc(shouldMime bool, contentType string) httpserver.Handler {
|
||||||
return httpserver.HandlerFunc(func(w http.ResponseWriter, r *http.Request) (int, error) {
|
return httpserver.HandlerFunc(func(w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
if shouldMime {
|
if shouldMime {
|
||||||
if w.Header().Get("Content-Type") != contentType {
|
if w.Header().Get("Content-Type") != contentType {
|
||||||
return 0, fmt.Errorf("expected Content-Type: %v, found %v", contentType, r.Header.Get("Content-Type"))
|
return 0, fmt.Errorf("expected Content-Type: %v, found %v", contentType, w.Header().Get("Content-Type"))
|
||||||
}
|
}
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user