Skip to content

Set response header content-type charset to nil#157

Open
khaapamyaki wants to merge 1 commit intokeathley:masterfrom
khaapamyaki:master
Open

Set response header content-type charset to nil#157
khaapamyaki wants to merge 1 commit intokeathley:masterfrom
khaapamyaki:master

Conversation

@khaapamyaki
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