Skip to content

Support duplicate custom request headers #2503

Closed

Description

@ayanrajpoot10

Please describe your feature request:

Currently, httpx does not support sending multiple custom headers with the same name. When -H is used multiple times for the same header (for example, -H "Test: 1" -H "Test: 2"), only the last value is preserved.

This happens because custom headers are currently stored using map[string]string, which only allows a single value per header name. To support duplicate headers properly, this should be changed to map[string][]string, similar to Go's standard http.Header implementation.

Additionally, r.Header.Set() should be replaced with r.Header.Add() so that all provided header values are included in the request instead of overwriting previous ones.

Describe the use case of this feature:

The HTTP protocol allows multiple header fields with the same name in certain cases. A common example is Set-Cookie, where multiple separate header entries are expected.

Standard tools like curl already support this behavior when multiple -H flags are provided for the same header. Go's own http.Header type is also implemented as map[string][]string for this reason.

Activity

  1. added
    Type: Enhancement
    on May 23, 2026
  2. sophymarine commented on May 25, 2026

    @sophymarine

    I hit this exact httpx issue last week. The tool maps custom headers to a flat map[string]string right before building the request, which silently drops duplicate keys. Many target servers use duplicate headers to spot automated scrapers during TLS fingerprints or redirect hops. Lose one, you get blocked. Bumping the internal storage type to map[string][]string and calling Go's native http.Header.Add instead of setting keys directly fixes this. It mimics curl cleanly.

  3. dogancanbakir commented on Jun 3, 2026

    @dogancanbakir
    Member

    @Mzack9999 thoughts?

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

Metadata

Metadata

Assignees

Labels

Type: Enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions