twirp-ruby icon indicating copy to clipboard operation
twirp-ruby copied to clipboard

Allow specifying charset in the content-type header

Open shouichi opened this issue 3 years ago • 2 comments

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.

shouichi avatar Jun 10 '22 10:06 shouichi

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 avatar Nov 29 '22 13:11 ismailakbudak

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

ismailakbudak avatar Nov 29 '22 13:11 ismailakbudak