Commit 387a0832 authored by spacewander's avatar spacewander

gzip,mime: show response header instead of the request one in test message

parent a6ec51b3
...@@ -109,10 +109,10 @@ func nextFunc(shouldGzip bool) httpserver.Handler { ...@@ -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 { ...@@ -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
} }
......
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