Skip to content

fix(httpx): stop sending Accept-Charset by default - #2751

Merged
Mzack9999 merged 1 commit into
devfrom
fix/drop-accept-charset
Nov 19, 2026
Merged

Mzack9999 merged 1 commit into
devfrom
fix/drop-accept-charset

Conversation

@dogancanbakir

@dogancanbakir dogancanbakir commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Fixes #2749

Drops the hard-coded Accept-Charset: utf-8. Body decoding uses the response charset, so output is unchanged; -H can still add it.
Behavior change: worth a line in the release notes.

Summary by CodeRabbit

  • Bug Fixes
    • Safe requests no longer include the Accept-Charset header by default. The default User-Agent remains unchanged.

@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Safe requests no longer receive the default Accept-Charset: utf-8 header. They continue to receive the configured default User-Agent. A test checks both header behaviors.

Changes

Request Header Behavior

Layer / File(s) Summary
Safe request headers
common/httpx/httpx.go, common/httpx/httpx_test.go
Safe requests no longer receive Accept-Charset: utf-8. The test checks that the configured default User-Agent remains.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: mzack9999, tassiosales

Merge Risk: Minimal · up to 286e7

httpx no longer sends a default Accept-Charset: utf-8 header, which reduces fingerprinting. Response decoding is unaffected. The change is small and tested. Mention it in the release notes because callers who relied on the header must now add it with -H.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the actual change: httpx no longer sends the hard-coded Accept-Charset header by default. The raw summary confirms that NewRequestWithContext drops this header for safe requests, and t…
Linked Issues check Passed Issue #2749 requires removing the default Accept-Charset: utf-8 header that httpx always sends. The diff to common/httpx/httpx.go removes the line req.Header.Add("Accept-Charset", "utf-8") from Ne…
Out of Scope Changes check Passed All changes are in scope. The only production change removes the default Accept-Charset header in common/httpx/httpx.go, which is the change requested by #2749. The removed User-Agent comment is a min…
Full details: Title check

Explanation

The title names the actual change: httpx no longer sends the hard-coded Accept-Charset header by default. The raw summary confirms that NewRequestWithContext drops this header for safe requests, and the test asserts its absence. The title uses the conventional fix(httpx) prefix and is specific enough for a teammate scanning history. It is 50 characters, which is within a concise range.

Full details: Linked Issues check

Explanation

Issue #2749 requires removing the default Accept-Charset: utf-8 header that httpx always sends. The diff to common/httpx/httpx.go removes the line req.Header.Add("Accept-Charset", "utf-8") from NewRequestWithContext. The header is no longer added to requests built by the default (safe) path. The User-Agent default remains set. The new test TestNewRequestOmitsAcceptCharset in common/httpx/httpx_test.go asserts that NewRequest omits Accept-Charset and keeps the configured User-Agent, which covers the automated test requirement. The PR description's claim that response decoding is unchanged is not verified by this diff. The issue does not require that claim, so it does not affect this verdict. The release-note item is non-coding and does not apply.

Full details: Out of Scope Changes check

Explanation

All changes are in scope. The only production change removes the default Accept-Charset header in common/httpx/httpx.go, which is the change requested by #2749. The removed User-Agent comment is a minor cleanup in the same block. The added test in common/httpx/httpx_test.go directly verifies the header removal. No unrelated files are changed in the whole-PR summary. The ignored_files list is empty, so no excluded paths affect this result.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit checks the headers with care,
Finds no charset waiting there.
The User-Agent stays in view,
A small test confirms it too.
Then hops away through morning dew.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: ad769fa2-1166-4585-88bf-15087c3bed42
Commits

Reviewing files that changed from the base of the PR and between 2226531 and 286e746.

Files selected for processing: 2

  • common/httpx/httpx.go
  • common/httpx/httpx_test.go
Files with no reviewable changes: 1

  • common/httpx/httpx.go

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

@Mzack9999
Mzack9999 merged commit 3ef0269 into dev Nov 19, 2026
12 checks passed
@Mzack9999
Mzack9999 deleted the fix/drop-accept-charset branch November 19, 2026 16:55
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.

Default Accept-Charset header gets requests blocked by some WAFs

2 participants