From b51e8bc191da8c84999797caeb0c998d4305d088 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Thu, 30 Apr 2015 07:50:07 -0600 Subject: [PATCH] fastcgi: Fix for handling errors that come from responder --- middleware/fastcgi/fastcgi.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/middleware/fastcgi/fastcgi.go b/middleware/fastcgi/fastcgi.go index 2e88013c..984dcb89 100644 --- a/middleware/fastcgi/fastcgi.go +++ b/middleware/fastcgi/fastcgi.go @@ -111,12 +111,15 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) w.WriteHeader(resp.StatusCode) // Write the response body + // TODO: If this has an error, the response will already be + // partly written. We should copy out of resp.Body into a buffer + // first, then write it to the response... _, err = io.Copy(w, resp.Body) if err != nil { return http.StatusBadGateway, err } - return resp.StatusCode, nil + return 0, nil } }