Repository navigation
Add default_headers request option to skip the client's default headers - #13
Merged
Merged
Conversation
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
trusche
requested review from
zyc9012
and
a balanced review from Copilot
and removed request for
zyc9012
November 26, 2026 09:49
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The README’s header-order claim needs qualification because header_order remains active with default_headers: false and can override Ruby hash order.
1 open issue
What changed in this PR
Adds a per-request default_headers option to the Ruby client, allowing callers to skip client-level headers while preserving TLS and HTTP/2 emulation settings.
Changes:
- Passes
default_headersthrough the shared request-options handler, supporting individual and batch requests. - Documents the option and adds a live regression test for suppressing client defaults.
- Updates Ruby and Rust package versions to 0.7.0.
| File | Description |
|---|---|
test/request_test.rb |
Tests that client defaults are omitted while request headers remain. |
README.md |
Documents the option and provides a usage example. |
lib/wreq-rb/version.rb |
Bumps the Ruby version to 0.7.0. |
ext/wreq_rb/src/client.rs |
Forwards the option to the underlying request builder. |
ext/wreq_rb/Cargo.toml |
Bumps the Rust extension version to 0.7.0. |
Cargo.lock |
Synchronizes the locked extension version. |
Review effort: Balanced
Clarified comments regarding TLS, HTTP/2 settings, and header order. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
zyc9012
approved these changes
Nov 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Opus 5.5 High
The client's emulation headers go out on every request, and a request can't remove them. Setting a header to
nilskips it, and a per-requestemulation: falsedoesn't remove client defaults either. So a Chrome emulation sends navigation headers (upgrade-insecure-requests: 1,sec-fetch-user: ?1,priority: u=0, i) also on requests where Chrome never sends them, such as a script load or afetch().Bumps the version to 0.7.0. Publishing still needs the v0.7.0 tag after merge.
Fix
wreq0.16.1 already has this:RequestBuilder::default_headers(false)(vendor/wreq/src/client/request.rs:287) skips the client's default headers for one request. This PR passes the new per-request optiondefault_headers:through to it inapply_request_options. Batch requests use the same function, so they support it too.What it does, checked on the wire with
tls.peet.ws:user_agentand itsheaders. The caller sends every header it wants.emulation:still adds its own headers, becausewreqwrites them into the request itself (request.rs:774).t13d1516h2and Akamai hash52d84b11with and without the option.Before and after on the wire
The same request through a fresh
chrome_143client, withdefault_headers: falseand the 12 headers Chrome sends when it loads a script.tls.peet.wsreports what it received:t13d1516h2_8daaf6152771_d8a2da3f94cd52d84b11737d980aef856699f885ca86upgrade-insecure-requests: 1sec-fetch-user: ?1The headers go out in the order of the Ruby hash. The hash below is not in Chrome's order; it only shows which headers are sent.
Headers received
Script
Testing
test_default_headers_false_sends_only_request_headers(httpbun, like the other request tests). It checks that the defaults are sent without the option, and thatSec-Fetch-User,Upgrade-Insecure-Requests,Sec-Ch-Ua,User-Agentand the client'sheadersare not sent with it. Without the change it fails withExpected "?1" to be nil.bundle exec rake test: 59 runs, 184 assertions, 0 failures. Rust tests: 1 passed.wreq0.16.1 needs 1.98 or newer.