aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pipkin.go17
1 files changed, 13 insertions, 4 deletions
diff --git a/pipkin.go b/pipkin.go
index 575d22e..556a493 100644
--- a/pipkin.go
+++ b/pipkin.go
@@ -7,6 +7,7 @@ import (
"encoding/hex"
"encoding/json"
"encoding/xml"
+ "errors"
"flag"
"fmt"
"html/template"
@@ -17,6 +18,7 @@ import (
"os"
"path"
"strings"
+ "syscall"
"time"
)
@@ -283,10 +285,17 @@ func (pk *Pipkin) fetch(w http.ResponseWriter, r *http.Request) {
// Stream response buffer directly to client; memory-efficient over
// io.ReadAll().
w.WriteHeader(resp.StatusCode)
- _, err = io.Copy(w, resp.Body)
- if err != nil {
- pk.log.Errorf("Error writing response body: %s %s %s: %s\n", hostStr,
- host.Bucket, key, err.Error())
+ if _, err = io.Copy(w, resp.Body); err != nil {
+ if errors.Is(err, syscall.ECONNRESET) {
+ pk.log.Infof("Connection reset: %s %s %s: %s\n", hostStr,
+ host.Bucket, key, err.Error())
+ } else if errors.Is(err, syscall.EPIPE) {
+ pk.log.Infof("Broken pipe: %s %s %s: %s\n", hostStr, host.Bucket,
+ key, err.Error())
+ } else {
+ pk.log.Errorf("Error writing response body: %s %s %s: %s\n",
+ hostStr, host.Bucket, key, err.Error())
+ }
}
}