HEAD shouldn't have any body, handle it in writeErrorResponse()

This commit is contained in:
Harshavardhana
2015-07-10 21:06:43 -07:00
parent 7fde241ee2
commit 7615a6bfe5
5 changed files with 17 additions and 35 deletions

View File

@@ -201,6 +201,9 @@ func writeErrorResponse(w http.ResponseWriter, req *http.Request, errorType int,
setCommonHeaders(w, getContentTypeString(acceptsContentType), len(encodedErrorResponse))
// write Header
w.WriteHeader(error.HTTPStatusCode)
// write error body
w.Write(encodedErrorResponse)
// HEAD should have no body
if req.Method != "HEAD" {
// write error body
w.Write(encodedErrorResponse)
}
}