parent
88aed988f9
commit
dd6ce92651
|
@ -457,6 +457,8 @@ func (handler *Handler) sendError(w http.ResponseWriter, r *http.Request, err er
|
|||
}
|
||||
|
||||
reason := err.Error() + "\n"
|
||||
|
||||
// Avoid sending a response to a HEAD request. They expect an empty body.
|
||||
if r.Method == "HEAD" {
|
||||
reason = ""
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ func TestHead(t *testing.T) {
|
|||
t.Errorf("Expected valid metadata (got '%s')", v)
|
||||
}
|
||||
|
||||
(&httpTest{
|
||||
res = (&httpTest{
|
||||
Name: "Non-existing file",
|
||||
Method: "HEAD",
|
||||
URL: "no",
|
||||
|
@ -64,6 +64,9 @@ func TestHead(t *testing.T) {
|
|||
ResHeader: map[string]string{
|
||||
"Content-Length": "0",
|
||||
},
|
||||
ResBody: "",
|
||||
}).Run(handler, t)
|
||||
|
||||
if string(res.Body.Bytes()) != "" {
|
||||
t.Errorf("Expected empty body for failed HEAD request")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue