Skip to content

Should there be support for base64 encoded binary header values in Metadata? #2566

Open
@richardjanssen

Description

@richardjanssen

In Grpc.Core.Metadata.Entry there are two constructors for creating metadata entries. One for string values and one for binary values. These constructors validate that the entry key either has or does not have a -bin suffix, depending on the used constructor. In practice these constructors are sometimes used to parse HTTP headers into metadata, e.g. here. I encountered a situation interacting with a Google Speech-to-Text API where headers with a -bin suffix are included in a HTTP response, but their values are Base64 encoded strings (of byte arrays). This causes exceptions to be thrown when creating Metadata from these responses, as string valued headers cannot have a -bin suffix.

I believe encoding binary headers to Base64 is a common practice and therefore wonder if such cases should be parsed correctly when creating Metadata entries? Or is it the responsibility of whoever decides to create the Metadata object that all headers have valid combinations of key value types?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions