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

In actual response content type is text/plain even for (default) http.JSONResultWriter #9

Closed
panta opened this issue Aug 5, 2021 · 2 comments

Comments

@panta
Copy link
Contributor

panta commented Aug 5, 2021

This doesn't happen with unit tests, maybe there is a difference when using httptest?
With a real handler I get the response with a text/plain Content-Type. I guess this is because the status is emitted before the Content-Type (ultimately set here).

@alexliesenfeld
Copy link
Owner

I understand. This is because WriteHeader is called before all headers are set (compare with golang/go#17083).

@alexliesenfeld
Copy link
Owner

alexliesenfeld commented Aug 9, 2021

I think the ResultWriter needs to write the status code as well. Otherwise we will need to split the functionality into multiple functions or there will be ordering issues. The develop branch has a fix for this.

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

2 participants