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

EncodeJSONResponse does not account for http.StatusNoContent #435

Closed
groob opened this issue Jan 12, 2017 · 2 comments
Closed

EncodeJSONResponse does not account for http.StatusNoContent #435

groob opened this issue Jan 12, 2017 · 2 comments

Comments

@groob
Copy link
Contributor

groob commented Jan 12, 2017

The current implementation of EncodeJSONResponse always writes an HTTP response body.
When the status should be http.StatusNoContent, there shouldn't be any response body.

In my own code I've done a check like this:

    if e, ok := response.(statusCoder); ok {
        w.WriteHeader(e.status())
        if e.status() == http.StatusNoContent {
            return nil
        }
    }

Should the EncodeJSONResponse have a check for 204 responses? I can send a PR but wanted to make sure it's wanted first.

@basvanbeek
Copy link
Member

I personally would expect it to play nice with expectations so +1 from me

@peterbourgon
Copy link
Member

SGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants