Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use httpsnoop to wrap ResponseWriter. #193

Merged
merged 1 commit into from
Aug 20, 2020

Commits on Aug 19, 2020

  1. Use httpsnoop to wrap ResponseWriter.

    Wrapping http.ResponseWriter is fraught with danger. Our compress
    handler made sure to implement all the optional ResponseWriter
    interfaces, but that made it implement them even if the underlying
    writer did not. For example, if the underlying ResponseWriter was
    _not_ an http.Hijacker, the compress writer nonetheless appeared to
    implement http.Hijacker, but would panic if you called Hijack().
    
    On the other hand, the logging handler checked for certain
    combinations of optional interfaces and only implemented them as
    appropriate. However, it didn't check for all optional interfaces or
    all combinations, so most optional interfaces would still get lost.
    
    Fix both problems by using httpsnoop to do the wrapping. It uses code
    generation to ensure correctness, and it handles std lib changes like
    the http.Pusher addition in Go 1.8.
    
    Fixes gorilla#169.
    Muir Manders committed Aug 19, 2020
    Configuration menu
    Copy the full SHA
    272f0a6 View commit details
    Browse the repository at this point in the history