Skip to content

Commit

Permalink
chore(query): Return content length header for queries (#6469) (#6479)
Browse files Browse the repository at this point in the history
This PR adds `Content-Length` header to the response of queries sent via HTTP.

Fixes DGRAPH-1675

(cherry picked from commit ed63786)
  • Loading branch information
Ibrahim Jarif authored Sep 28, 2020
1 parent 3afbb98 commit 4922a28
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion x/x.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 4922a28

Please sign in to comment.