grpc-swift
grpc-swift copied to clipboard
Duplicate content_type headers
Describe the bug
If we set content_type header in custom_metadata (application/grpc), the library itself adds content_type header too.
So the request contains duplicate content_type headers and this could be lead to failure if the server doesn't handle duplication.
We should certainly handle this -- and other user provided headers -- better than we do now. I'm undecided whether in the general case we should defer to user provided values or remove duplicates. It probably depends on the header name (i.e. "content-type" feels like one we should add only if the user didn't provide one yet something like ":path" should be ignored or emit an error if a user provides it).
Out of curiosity, why do you set a custom content-type header?
Thanks @glbrntt.
Since we use other protocols for our requests(like HTTP and octet-stream types), we have defined a RequestHeaderProtocol in our app which services(containing gRPC service) get their headers from there.
One of the headers this protocol puts in headers is content-type. After found that this issue exists, I removed this header from GRPCHeader: RequestHeaderProtocol, and the problem was solved.
I saw many gRPC clients on mac don't allow the user to set duplicate headers. So I agree with you that any pre-defined header set in custom metadata should be ignored before the request happens.