Skip to content

feat(gax): request-level custom HTTP/gRPC headers - #6260

Open
xlai20 wants to merge 5 commits into
googleapis:mainfrom
xlai20:request-custom-header
Open

feat(gax): request-level custom HTTP/gRPC headers#6260
xlai20 wants to merge 5 commits into
googleapis:mainfrom
xlai20:request-custom-header

Conversation

@xlai20

@xlai20 xlai20 commented Aug 3, 2026

Copy link
Copy Markdown
Member

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:
    • Added default method with_custom_header<K, V>(mut self, name: K, value: V) -> Self to RequestOptionsBuilder.
  • google-cloud-gax-internal:
    • Updated ReqwestClient::request() to extract custom headers and enforce a "System-Wins" precedence policy.
  • Tests:
    • Added unit tests for RequestOptionsBuilder::with_custom_header.
    • Added HTTP transport wire emission and precedence tests in http_custom_header.rs (via echo_server).
    • Integration tests will be added later in google-cloud-storage upon version bump in next PR.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/gax-internal/src/http.rs Outdated
Comment thread src/gax/src/options.rs
@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.24%. Comparing base (35b9590) to head (7a54bb5).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@xlai20
xlai20 force-pushed the request-custom-header branch from 37c3082 to 0c1facd Compare August 4, 2026 06:25
@xlai20 xlai20 changed the title feat(gax): support request-level custom HTTP/gRPC headers feat(gax): request-level custom HTTP/gRPC headers Aug 4, 2026
@xlai20
xlai20 force-pushed the request-custom-header branch from 0c1facd to 7a54bb5 Compare August 4, 2026 06:48
@xlai20
xlai20 marked this pull request as ready for review August 4, 2026 06:52
@xlai20
xlai20 requested a review from a team as a code owner August 4, 2026 06:52
@xlai20
xlai20 requested a review from joshuatants August 4, 2026 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant