Skip to content

Commit dca9b49

Browse files
committed
Silence CodeQL warning
1 parent 1b293d9 commit dca9b49

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

example/http-server/main.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"fmt"
55
"github.com/davecgh/go-spew/spew"
6+
"html"
67
"net/http"
78
"net/http/httputil"
89
"os"
@@ -23,16 +24,8 @@ func headers(w http.ResponseWriter, req *http.Request) {
2324
}
2425
spew.Dump(dump)
2526

26-
for name, headers := range req.Header {
27-
for _, h := range headers {
28-
29-
_, err := fmt.Fprintf(w, "%v: %v\n", name, h)
30-
if err != nil {
31-
fmt.Printf("Error writing header %s: %v\n", name, err)
32-
return
33-
}
34-
}
35-
}
27+
w.Header().Set("Content-Type", "text/html; charset=utf-8")
28+
w.Write([]byte(html.EscapeString(string(dump))))
3629
}
3730

3831
func main() {

0 commit comments

Comments
 (0)