diff --git a/example/http-server/main.go b/example/http-server/main.go index e7d0782..4a1e04a 100644 --- a/example/http-server/main.go +++ b/example/http-server/main.go @@ -6,6 +6,7 @@ import ( "net/http" "net/http/httputil" "os" + "strings" ) func getPort() string { @@ -16,6 +17,8 @@ func getPort() string { return port } +var httpHeaderValueSanitizer = strings.NewReplacer("\n", "-", "\r", "-") + func headers(w http.ResponseWriter, req *http.Request) { dump, err := httputil.DumpRequest(req, true) if err != nil { @@ -25,8 +28,7 @@ func headers(w http.ResponseWriter, req *http.Request) { for name, headers := range req.Header { for _, h := range headers { - - _, err := fmt.Fprintf(w, "%v: %v\n", name, h) + _, err := fmt.Fprintf(w, "%v: %v\n", name, httpHeaderValueSanitizer.Replace(h)) if err != nil { fmt.Printf("Error writing header %s: %v\n", name, err) return