Skip to content

feat(requests): support custom amz headers#204

Open
overtrue wants to merge 1 commit into
mainfrom
overtrue/fix-custom-request-headers
Open

feat(requests): support custom amz headers#204
overtrue wants to merge 1 commit into
mainfrom
overtrue/fix-custom-request-headers

Conversation

@overtrue
Copy link
Copy Markdown
Contributor

Related issue

Closes #199

Background

Some S3-compatible services require custom x-amz-* request headers for bucket or object operations. The CLI did not expose a way to pass those headers.

Solution

  • Add a global -H/--header NAME:VALUE option for x-amz-* request headers
  • Inject custom headers before SigV4 signing for SDK-backed S3 requests
  • Apply the same headers to manual XML S3 requests before signing
  • Cover CLI parsing, help discoverability, and signed request behavior with tests

Validation

  • make pre-commit

Copilot AI review requested due to automatic review settings May 16, 2026 05:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a global -H/--header NAME:VALUE option that injects custom x-amz-* headers into both SDK-driven and manual XML S3 requests, signing them as part of SigV4.

Changes:

  • New RequestHeader type plus set_global_request_headers/global_request_headers (process-wide OnceLock<RwLock<...>>) in rc-core, with parsing that enforces the x-amz- prefix and basic header validity.
  • New global Clap arg request_headers parsed via RequestHeader::parse; execute populates the global before dispatch.
  • S3Client::new reads the globals once, attaches a CustomHeaderInterceptor (modify_before_signing) for SDK calls and inserts headers into the manual XML signing path before sign_xml_request.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
crates/core/src/alias.rs Defines RequestHeader and global header storage with parse-time validation.
crates/core/src/lib.rs Re-exports the new header types/functions.
crates/cli/src/commands/mod.rs Adds the -H/--header global flag, value parser, and seeds the global registry; adds parse-tests.
crates/cli/tests/help_contract.rs Asserts --header appears in help output.
crates/s3/src/client.rs Adds CustomHeaderInterceptor for SDK requests, applies headers before SigV4 in the manual XML path, plus a new SDK-path test.
docs/reference/rc/README.md Documents the new -H/--header global option.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e6d2e68877

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/s3/src/client.rs
@overtrue overtrue force-pushed the overtrue/fix-custom-request-headers branch from e6d2e68 to 69aa18b Compare May 16, 2026 05:54
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.

Add custom header to requests

2 participants