Skip to content
This repository has been archived by the owner on Mar 20, 2023. It is now read-only.

Commit

Permalink
Don't report error from bytes.Buffer WriteTo method
Browse files Browse the repository at this point in the history
  • Loading branch information
jung-kurt committed Dec 20, 2018
1 parent 0de79a2 commit 2d3cc15
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
1 change: 0 additions & 1 deletion cgi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ func TestInspect(t *testing.T) {
_, err = buf.ReadFrom(res.Body)
if err == nil {
str := buf.String()
fmt.Printf("%s\n", str)
if !strings.Contains(str, "CGI for Caddy") {
err = fmt.Errorf("unexpected response for \"inspect\" request")
}
Expand Down
6 changes: 1 addition & 5 deletions inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ type kvType struct {

func inspect(hnd cgi.Handler, w http.ResponseWriter, req *http.Request, rep httpserver.Replacer) {
var buf bytes.Buffer
var err error

printf := func(format string, args ...interface{}) {
fmt.Fprintf(&buf, format, args...)
Expand Down Expand Up @@ -102,8 +101,5 @@ func inspect(hnd cgi.Handler, w http.ResponseWriter, req *http.Request, rep http
repPrint("{.}", "{host}", "{match}", "{method}", "{root}", "{when}")

w.Header().Set("Content-Type", "text/plain; charset=utf-8")
_, err = buf.WriteTo(w)
if err != nil {
fmt.Fprintf(hnd.Stderr, "%s", err)
}
buf.WriteTo(w)
}

0 comments on commit 2d3cc15

Please sign in to comment.