diff --git a/x/x.go b/x/x.go index d8d0ab28450..69790da9a22 100644 --- a/x/x.go +++ b/x/x.go @@ -441,7 +441,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.