summaryrefslogtreecommitdiff
path: root/service/http/response.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-08-27 17:24:52 +0300
committerValery Piashchynski <[email protected]>2020-08-27 17:24:52 +0300
commita7f8371096fce063d64d0ea3e780685a366c537b (patch)
treec7c04e87d0f1b8e655eb652804cb05a2e3873d1a /service/http/response.go
parent9103939fa98de53170d2bf0e8cd74529786d7ab2 (diff)
Issue with broken pipe properly handled
Diffstat (limited to 'service/http/response.go')
-rw-r--r--service/http/response.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/service/http/response.go b/service/http/response.go
index 0942b3d2..045f56da 100644
--- a/service/http/response.go
+++ b/service/http/response.go
@@ -1,14 +1,21 @@
package http
import (
- json "github.com/json-iterator/go"
+ "errors"
"io"
+ "net"
"net/http"
+ "os"
"strings"
+ "syscall"
+
+ json "github.com/json-iterator/go"
"github.com/spiral/roadrunner"
)
+var errEPIPE = errors.New("EPIPE(32) -> possibly connection reset by peer")
+
// Response handles PSR7 response logic.
type Response struct {
// Status contains response status.
@@ -57,6 +64,13 @@ func (r *Response) Write(w http.ResponseWriter) error {
if data, ok := r.body.([]byte); ok {
_, err := w.Write(data)
if err != nil {
+ if netErr, ok2 := err.(*net.OpError); ok2 {
+ if syscallErr, ok3 := netErr.Err.(*os.SyscallError); ok3 {
+ if syscallErr.Err == syscall.EPIPE {
+ return errEPIPE
+ }
+ }
+ }
return err
}
}