summaryrefslogtreecommitdiff
path: root/service/http/response.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-08-27 22:34:41 +0300
committerValery Piashchynski <[email protected]>2020-08-27 22:34:41 +0300
commit50d12dcb0649836db1ac8670720fa0112c430b1e (patch)
tree20ea0240aae418f399b1df3a35bf993528ca5d68 /service/http/response.go
parenta7f8371096fce063d64d0ea3e780685a366c537b (diff)
handle aborted connection on windows
Diffstat (limited to 'service/http/response.go')
-rw-r--r--service/http/response.go24
1 files changed, 15 insertions, 9 deletions
diff --git a/service/http/response.go b/service/http/response.go
index 045f56da..ebb90994 100644
--- a/service/http/response.go
+++ b/service/http/response.go
@@ -1,3 +1,5 @@
+// +build !windows
+
package http
import (
@@ -14,7 +16,7 @@ import (
"github.com/spiral/roadrunner"
)
-var errEPIPE = errors.New("EPIPE(32) -> possibly connection reset by peer")
+var errEPIPE = errors.New("EPIPE(32) -> connection reset by peer")
// Response handles PSR7 response logic.
type Response struct {
@@ -64,14 +66,7 @@ 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
+ return handleWriteError(err)
}
}
@@ -84,6 +79,17 @@ func (r *Response) Write(w http.ResponseWriter) error {
return nil
}
+func handleWriteError(err error) error {
+ if netErr, ok2 := err.(*net.OpError); ok2 {
+ if syscallErr, ok3 := netErr.Err.(*os.SyscallError); ok3 {
+ if syscallErr.Err == syscall.EPIPE {
+ return errEPIPE
+ }
+ }
+ }
+ return err
+}
+
func handlePushHeaders(h map[string][]string) []string {
var p []string
pushHeader, ok := h[http2pushHeaderKey]