Skip to content

superfluous response.WriteHeader call #32

Open

Description

@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?

Activity

  1. rmhubbert commented on Sep 17, 2025

    @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.

  2. infogulch commented on Sep 18, 2025

    @infogulch
    Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions