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

fileserver: Better handling of HTTP status override #4132

Merged
merged 2 commits into from
Apr 29, 2021

Commits on Apr 24, 2021

  1. fileserver: Don't need io.Copy in error handling

    Just something I noticed when reading through the code; I think the `io.Copy` was a remnant of an older version of that code. I don't see a reason why we don't just let it fall through and serve the file with `http.ServeContent` normally. More consistent that way.
    
    Also, I hoisted the `status_code` override logic above the error handler detection bit, because then it allows for overriding the status code during error routes. Not necessarily that likely to be useful, but it's more correct. (Reminder that the first `w.WriteHeader()` wins, subsequent ones have no effect)
    francislavoie committed Apr 24, 2021
    Configuration menu
    Copy the full SHA
    b2ce6bb View commit details
    Browse the repository at this point in the history

Commits on Apr 28, 2021

  1. fileserver: Set the status via a custom response writer

    This makes sure additional header fields can be set by `http.ServeContent`, by only intercepting the `WriteHeader` call when `http.ServeContent` actually calls it.
    francislavoie committed Apr 28, 2021
    Configuration menu
    Copy the full SHA
    bc7a8f5 View commit details
    Browse the repository at this point in the history