From dca9b49192d139b74f29c920f05aeb4fa14353c3 Mon Sep 17 00:00:00 2001 From: Ingmar Stein Date: Mon, 27 May 2024 21:26:40 +0200 Subject: [PATCH] Silence CodeQL warning --- example/http-server/main.go | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/example/http-server/main.go b/example/http-server/main.go index e7d0782..9462389 100644 --- a/example/http-server/main.go +++ b/example/http-server/main.go @@ -3,6 +3,7 @@ package main import ( "fmt" "github.com/davecgh/go-spew/spew" + "html" "net/http" "net/http/httputil" "os" @@ -23,16 +24,8 @@ func headers(w http.ResponseWriter, req *http.Request) { } spew.Dump(dump) - for name, headers := range req.Header { - for _, h := range headers { - - _, err := fmt.Fprintf(w, "%v: %v\n", name, h) - if err != nil { - fmt.Printf("Error writing header %s: %v\n", name, err) - return - } - } - } + w.Header().Set("Content-Type", "text/html; charset=utf-8") + w.Write([]byte(html.EscapeString(string(dump)))) } func main() {