Skip to content

Commit c7dcef5

Browse files
committed
catch EOF errors, log all else
1 parent d5e967e commit c7dcef5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

relay/traffic/handler.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package traffic
33
import (
44
"bytes"
55
"crypto/tls"
6+
"errors"
67
"fmt"
78
"io"
89
"log"
@@ -139,7 +140,10 @@ func (handler *Handler) handleHttp(clientResponse http.ResponseWriter, clientReq
139140
if _, err := io.CopyN(clientResponse, targetResponse.Body, handler.config.MaxBodySize); err != nil {
140141
// NOTE: it is highly likely the server would come back without a content-length especially with
141142
// mobile traffic. In this case, full copy happens but we get an EOF error that can be safely
142-
// ignored. See this example: https://go.dev/play/p/8T3kbRfk_vO
143+
// ignored. See this example: https://go.dev/play/p/xotsgkwhJis
144+
if !errors.Is(err, io.EOF) {
145+
logger.Printf("Error relaying response body with unknown content-length: %s", err)
146+
}
143147
}
144148
} else {
145149
clientResponse.WriteHeader(targetResponse.StatusCode)

0 commit comments

Comments
 (0)