Skip to content

Commit

Permalink
chore(query): Return content length header for queries (#6469) (#6478)
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 9732c30 commit 780021b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion dgraph/cmd/alpha/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,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
}

// This method should just build the request and proxy it to the Query method of dgraph.Server.
Expand Down

0 comments on commit 780021b

Please sign in to comment.