Skip to content

Configure the TLS hostname header - #421

Open
Aschenbath wants to merge 1 commit into
requests:mainfrom
Aschenbath:codex/oss20-20261122b-de52-toolbelt-host-header
Open

Aschenbath wants to merge 1 commit into
requests:mainfrom
Aschenbath:codex/oss20-20261122b-de52-toolbelt-host-header

Conversation

@Aschenbath

Copy link
Copy Markdown

Add opt-in use_header and strip_header options to HostHeaderSSLAdapter. A custom case-insensitive header can select the certificate verification and SNI hostname independently of HTTP Host; stripping keeps that control header out of the outgoing request. Defaults preserve existing behavior, missing headers clear previous overrides, and adapter pickling retains the options.

Fixes #189.

Validation: 5 new pytest cases pass on Python 3.12; 4 existing network tests remain skipped. Four regressions fail before the change. Tests inspect prepared requests and pool configuration with HTTPAdapter.send mocked, including header stripping, reset and pickle. Changed-file Flake8 passes; Sphinx builds with the unchanged theme deprecation warning. No live TLS connection or Python 2.7 test was performed.

This change was prepared with AI assistance.

The HTTP Host value sometimes needs to differ from the TLS hostname.
Allow callers to select a separate control header and optionally strip
it before sending, while preserving the current default behavior.

Closes requests#189
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.

HostHeaderSSLAdapter Doesn't appear to handle alternate ports

1 participant