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

Should not set header after WriteHeader in example #537

Closed
bcho opened this issue May 26, 2017 · 0 comments
Closed

Should not set header after WriteHeader in example #537

bcho opened this issue May 26, 2017 · 0 comments

Comments

@bcho
Copy link
Contributor

bcho commented May 26, 2017

In shipping example: https://github.com/go-kit/kit/blame/master/examples/shipping/booking/transport.go#L184

encodeError may write header before setting the content-type header. From go net/http's doc:

Changing the header map after a call to WriteHeader (or Write) has no effect unless the modified headers are trailers.

Seems like the content-type header should set before the error switch.

bcho added a commit to bcho/kit that referenced this issue May 26, 2017
From `net/http`:

    Changing the header map after a call to WriteHeader (or Write)
    has no effect unless the modified headers are trailers.

To send the `content-type`, need to set before calling `WriteHeader`.

Fixes go-kit#537
jamesgist pushed a commit to jamesgist/kit that referenced this issue Nov 1, 2024
From `net/http`:

    Changing the header map after a call to WriteHeader (or Write)
    has no effect unless the modified headers are trailers.

To send the `content-type`, need to set before calling `WriteHeader`.

Fixes go-kit#537
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

1 participant