feat(gax): request-level custom HTTP/gRPC headers - #6260
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for injecting custom HTTP headers into requests via RequestOptionsBuilder::with_custom_header, along with comprehensive integration and unit tests. The review feedback highlights two key issues: first, the current logic for merging system headers silently discards multi-valued headers due to how HeaderMap iteration works; second, swallowing conversion errors when parsing custom header names and values violates the "Demand Explosive Correctness" principle, and should instead fail loudly.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6260 +/- ##
==========================================
- Coverage 96.24% 96.24% -0.01%
==========================================
Files 280 280
Lines 72146 72195 +49
==========================================
+ Hits 69440 69485 +45
- Misses 2706 2710 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
37c3082 to
0c1facd
Compare
0c1facd to
7a54bb5
Compare
Overview
Adds support for request-level custom HTTP/gRPC headers via
RequestOptionsBuilder::with_custom_header, allowing developers to inject tracking or tracing headers (e.g.,x-client-tracking-id,X-B3-TraceId) on individual API calls without signature changes.DD: go/rust-sdk-custom-header
Part of #5997
Key Changes
google-cloud-gax:with_custom_header<K, V>(mut self, name: K, value: V) -> SelftoRequestOptionsBuilder.google-cloud-gax-internal:ReqwestClient::request()to extract custom headers and enforce a "System-Wins" precedence policy.RequestOptionsBuilder::with_custom_header.http_custom_header.rs(viaecho_server).