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

Set response header content-type charset to nil #157

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

daskycodes
Copy link

The twirp ruby client explicitly expects the content-type to be either "application/json" or "application/protobuf".

https://github.com/twitchtv/twirp-ruby/blob/main/lib/twirp/encoding.rb#L19-L24

This leads to following error:

=> #<Twirp::ClientResp:0x00007fdf03c1eed8 
  @data=nil, 
  @error= <Twirp::Error 
    code:internal 
    msg:"Expected response Content-Type \"application/protobuf\" but found \"application/protobuf; charset=utf-8\"" 
    meta:{}
  >
>

This also conforms with the Twirp v7 spec:

Content-Type The value should be either "application/protobuf" or "application/json" to indicate the encoding of the response message. It must match the "Content-Type" header in the request.
https://github.com/twitchtv/twirp/blob/ded153e52e9e279471e020135e42e5e3f1000276/docs/spec_v7.md#responses

This PR sets the content-type's charset to nil to explicitly remove the default utf8 charset

https://hexdocs.pm/plug/Plug.Conn.html#put_resp_content_type/3

@hernanat
Copy link

bump

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

Successfully merging this pull request may close these issues.

2 participants