diff options
author | Yash Tibrewal <yashkt@google.com> | 2018-09-04 19:18:15 -0700 |
---|---|---|
committer | Yash Tibrewal <yashkt@google.com> | 2018-09-04 19:19:03 -0700 |
commit | 3a41245e465e176dc2cae642cf701f5b476188b6 (patch) | |
tree | a56134db1239548b395139987c4115409fd6589f /src/core/ext/filters/http | |
parent | dd95194a086b81966fd94726c04f53d279e247d8 (diff) |
Rectify the condition and add a test
Diffstat (limited to 'src/core/ext/filters/http')
-rw-r--r-- | src/core/ext/filters/http/client/http_client_filter.cc | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/core/ext/filters/http/client/http_client_filter.cc b/src/core/ext/filters/http/client/http_client_filter.cc index f44dc032a7..91fa163fec 100644 --- a/src/core/ext/filters/http/client/http_client_filter.cc +++ b/src/core/ext/filters/http/client/http_client_filter.cc @@ -79,7 +79,12 @@ struct channel_data { static grpc_error* client_filter_incoming_metadata(grpc_call_element* elem, grpc_metadata_batch* b) { if (b->idx.named.status != nullptr) { - if (grpc_mdelem_eq(b->idx.named.status->md, GRPC_MDELEM_STATUS_200)) { + /* If both gRPC status and HTTP status are provided in the response, we + * should prefer the gRPC status code, as mentioned in + * https://github.com/grpc/grpc/blob/master/doc/http-grpc-status-mapping.md. + */ + if (b->idx.named.grpc_status != nullptr || + grpc_mdelem_eq(b->idx.named.status->md, GRPC_MDELEM_STATUS_200)) { grpc_metadata_batch_remove(b, b->idx.named.status); } else { char* val = grpc_dump_slice(GRPC_MDVALUE(b->idx.named.status->md), |