superfluous response.WriteHeader call

#32 · open · 2 comments

View on GitHub ↗

infogulch

`http: superfluous response.WriteHeader call from github.com/felixge/httpsnoop.(*Metrics).CaptureMetrics.func1.1 (capture_metrics.go:53)` I sometimes get this error in my logs when serving static files with `http.ServeContent`. Not sure how this happens if the wrapper is working correctly but the logs don't lie. Maybe `ServeContent` is somehow getting direct access to the underlying writer?

Comments

rmhubbert

@infogulch I was seeing this error as well on my endpoints served by http.FileServer. In my case, it was caused by me calling ServeHttp on the handler that I was also passing to CaptureMetrics. I didn't realise that CaptureMetrics runs ServeHttp on the Handler that you pass to it. Removing my additional direct call to ServeHttp on the original handler fixed the issue.

infogulch

I think this only occurs when serving a file with `http.ServeContent`. It consistently shows up in the logs at least once.