Skip to content

Commit

Permalink
authorizer: Improve error handle to response pipe error
Browse files Browse the repository at this point in the history
* Properly handle and report the response pipe error.
  • Loading branch information
yookoala committed Oct 13, 2020
1 parent 5c05ccd commit 82c8d53
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion authorizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,12 @@ func (ar Authorizer) Wrap(inner http.Handler) http.Handler {

ew := new(bytes.Buffer)
rw := httptest.NewRecorder() // FIXME: should do this without httptest
resp.WriteTo(rw, ew)
if err = resp.WriteTo(rw, ew); err != nil {
log.Printf("cannot write to response pipe: %s", err)
w.WriteHeader(http.StatusInternalServerError)
fmt.Fprintf(w, http.StatusText(http.StatusInternalServerError))
return
}

// if code is not http.StatusOK (200)
if rw.Code != http.StatusOK {
Expand Down

0 comments on commit 82c8d53

Please sign in to comment.