recovery: fix issue about syscall import on google app engine (#1640)
* recovery: fix issue about syscall import on google app engine * add ToLower() * the whole error message
This commit is contained in:
parent
3d44ff82a1
commit
7ec82ee894
@ -15,7 +15,7 @@ import (
|
|||||||
"net/http/httputil"
|
"net/http/httputil"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
"syscall"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ func RecoveryWithWriter(out io.Writer) HandlerFunc {
|
|||||||
var brokenPipe bool
|
var brokenPipe bool
|
||||||
if ne, ok := err.(*net.OpError); ok {
|
if ne, ok := err.(*net.OpError); ok {
|
||||||
if se, ok := ne.Err.(*os.SyscallError); ok {
|
if se, ok := ne.Err.(*os.SyscallError); ok {
|
||||||
if se.Err == syscall.EPIPE || se.Err == syscall.ECONNRESET {
|
if strings.Contains(strings.ToLower(se.Error()), "broken pipe") || strings.Contains(strings.ToLower(se.Error()), "connection reset by peer") {
|
||||||
brokenPipe = true
|
brokenPipe = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,8 +84,8 @@ func TestPanicWithBrokenPipe(t *testing.T) {
|
|||||||
const expectCode = 204
|
const expectCode = 204
|
||||||
|
|
||||||
expectMsgs := map[syscall.Errno]string{
|
expectMsgs := map[syscall.Errno]string{
|
||||||
syscall.EPIPE: "broken pipe",
|
syscall.EPIPE: "Broken pipe",
|
||||||
syscall.ECONNRESET: "connection reset",
|
syscall.ECONNRESET: "connection reset by peer",
|
||||||
}
|
}
|
||||||
|
|
||||||
for errno, expectMsg := range expectMsgs {
|
for errno, expectMsg := range expectMsgs {
|
||||||
|
Loading…
Reference in New Issue
Block a user