From 4922a2811290630f0d84b82c27aba3ccd2e76425 Mon Sep 17 00:00:00 2001 From: Ibrahim Jarif Date: Mon, 28 Sep 2020 23:55:42 +0530 Subject: [PATCH] chore(query): Return content length header for queries (#6469) (#6479) This PR adds `Content-Length` header to the response of queries sent via HTTP. Fixes DGRAPH-1675 (cherry picked from commit ed63786522c9539059d2131750327fa1bfcfee6c) --- x/x.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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.