summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-08-27 22:38:46 +0300
committerValery Piashchynski <[email protected]>2020-08-27 22:38:46 +0300
commitf6e5e0e4801109f0b53b9f637fbf9d3949979a96 (patch)
tree42385a9fbdf242264ff20efaa2d920cc9a7436ac
parent50d12dcb0649836db1ac8670720fa0112c430b1e (diff)
Update error handler
-rw-r--r--service/http/errors.go24
-rw-r--r--service/http/errors_windows.go (renamed from service/http/response_windows.go)4
-rw-r--r--service/http/response.go18
3 files changed, 26 insertions, 20 deletions
diff --git a/service/http/errors.go b/service/http/errors.go
new file mode 100644
index 00000000..bdf10332
--- /dev/null
+++ b/service/http/errors.go
@@ -0,0 +1,24 @@
+// +build !windows
+
+package http
+
+import (
+ "errors"
+ "net"
+ "os"
+ "syscall"
+)
+
+var errEPIPE = errors.New("EPIPE(32) -> connection reset by peer")
+
+// handleWriteError just check if error was caused by aborted connection on linux
+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
+}
diff --git a/service/http/response_windows.go b/service/http/errors_windows.go
index f1ac6a37..a03c697e 100644
--- a/service/http/response_windows.go
+++ b/service/http/errors_windows.go
@@ -11,7 +11,7 @@ import (
var errEPIPE = errors.New("WSAECONNABORTED (10053) -> an established connection was aborted")
-// handleWriteError just check if error was caused by aborted connection
+// handleWriteError just check if error was caused by aborted connection on windows
func handleWriteError(err error) error {
if netErr, ok2 := err.(*net.OpError); ok2 {
if syscallErr, ok3 := netErr.Err.(*os.SyscallError); ok3 {
@@ -21,4 +21,4 @@ func handleWriteError(err error) error {
}
}
return err
-}
+} \ No newline at end of file
diff --git a/service/http/response.go b/service/http/response.go
index ebb90994..f34754be 100644
--- a/service/http/response.go
+++ b/service/http/response.go
@@ -1,22 +1,15 @@
-// +build !windows
-
package http
import (
- "errors"
"io"
- "net"
"net/http"
- "os"
"strings"
- "syscall"
json "github.com/json-iterator/go"
"github.com/spiral/roadrunner"
)
-var errEPIPE = errors.New("EPIPE(32) -> connection reset by peer")
// Response handles PSR7 response logic.
type Response struct {
@@ -79,17 +72,6 @@ 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]