Skip to content

Commit

Permalink
chore(query): Return content length header for queries (#6469)
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
  • Loading branch information
Ibrahim Jarif authored Sep 17, 2020
1 parent c9f8967 commit ed63786
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 @@ -486,7 +486,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 ed63786

Please sign in to comment.