Skip to content

tool: enable header separation when using a proxy#20398

Closed
jacekmigacz wants to merge 1 commit intocurl:masterfrom
jacekmigacz:fix/http-proxy-duplicate-user-agent
Closed

tool: enable header separation when using a proxy#20398
jacekmigacz wants to merge 1 commit intocurl:masterfrom
jacekmigacz:fix/http-proxy-duplicate-user-agent

Conversation

@jacekmigacz
Copy link
Contributor

CURLHEADER_SEPARATE was only set when --proxy-header was used, causing --header content to leak into CONNECT requests. This breaks some corporate proxies when custom User-Agent headers are specified.

Enable CURLHEADER_SEPARATE whenever --proxy is configured to ensure proper header separation:

  • --header affects only HTTP requests (not CONNECT)
  • --proxy-header affects only CONNECT requests
  • --user-agent affects both consistently

Before:
$ curl --proxy proxy:3128 --header "User-Agent: custom" https://example.com

CONNECT: User-Agent: curl/8.x
CONNECT: User-Agent: custom (leaked from --header)

After:
$ curl --proxy proxy:3128 --header "User-Agent: custom" https://example.com

CONNECT: User-Agent: curl/8.x
GET: User-Agent: custom

When using a proxy, --header specified headers were leaking into
CONNECT requests. This could break corporate proxies that reject
custom User-Agent headers in CONNECT.

Enable CURLHEADER_SEPARATE only for HTTPS through proxy or when
--proxytunnel is used, ensuring:
- --header affects only HTTP requests (not CONNECT)
- --proxy-header affects only CONNECT requests
- --user-agent affects both consistently

Fixes the redirect + proxy + custom UA issue while maintaining
compatibility with HTTP proxy scenarios.
@jacekmigacz jacekmigacz force-pushed the fix/http-proxy-duplicate-user-agent branch from 765fa88 to 24d4f61 Compare January 22, 2026 12:22
@testclutch
Copy link

Analysis of PR #20398 at 24d4f611:

Test 3023 failed, which has NOT been flaky recently, so there could be a real issue in this PR. Note that this test has failed in 12 different CI jobs (the link just goes to one of them).

Generated by Testclutch

@jacekmigacz jacekmigacz marked this pull request as ready for review January 22, 2026 13:08
@bagder bagder closed this in aacbe4d Jan 22, 2026
@bagder
Copy link
Member

bagder commented Jan 22, 2026

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants