diff --git a/x/x.go b/x/x.go index cadee0a4927..c0a42f7dbad 100644 --- a/x/x.go +++ b/x/x.go @@ -378,7 +378,12 @@ func WriteResponse(w http.ResponseWriter, r *http.Request, b []byte) (int, error out = gzw } - return out.Write(b) + bytesWritten, err := out.Write(b) + if err != nil { + return 0, err + } + w.Header().Set("Content-Length", strconv.FormatInt(int64(bytesWritten), 10)) + return bytesWritten, nil } // Min returns the minimum of the two given numbers.