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

This commit is contained in:
spacewander 2017-07-08 11:53:34 +08:00
parent a6ec51b349
commit 387a083255
2 changed files with 3 additions and 3 deletions

View File

@ -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)

View File

@ -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
} }