arthurnn / twirp-ruby

Twirp services in Ruby
Apache License 2.0
155 stars 60 forks source link

Allow specifying charset in the content-type header #89

Open shouichi opened 2 years ago

shouichi commented 2 years ago

Some HTTP clients always append charset to the content-type header e.g., content-type: application/json; charset=utf8. Requests made by those clients are rejected because of the content-type mismatch.

Twirp only allows the content-type header exactly matches one of aplication/json, application/json; strict=true or application/probobuf. This seems too strict, can we relax this constraint?

Thank you.

ismailakbudak commented 1 year ago

We are trying to send the application/grpc header. We override some parts of the code but, why is so strict, and do you know about the difference? Server is external server, so we can not see the server side :(

ismailakbudak commented 1 year ago

We are trying to send the application/grpc header. We override some parts of the code but, why is so strict, and do you know about the difference? Server is external server, so we can not see the server side :(

We changed following part;

module Twirp

  module Encoding
    JSON = "application/json"
    # An opt-in content type useful when curling or manually testing a twirp
    # service.  This will fail if unknown fields are encountered. The return
    # content type will be application/json.
    JSON_STRICT = "application/json; strict=true"
    # PROTO = "application/protobuf"
    PROTO = "application/grpc"

But when we try to read response from the server it is empty