Skip to content

Request headers whose value matches the request URI host are dropped from curl and HTTPie snippets - #1056

Open
harrisleesh wants to merge 1 commit into
spring-projects:mainfrom
harrisleesh:gh-1053
Open

harrisleesh wants to merge 1 commit into
spring-projects:mainfrom
harrisleesh:gh-1053

Conversation

@harrisleesh

Copy link
Copy Markdown

Fixes gh-1053

HostHeaderFilter.allow(name, value) never inspected the header name, so any header whose first value matched the request URI's host (e.g. X-Forwarded-Host: localhost on a request to http://localhost/foo) was silently dropped from generated curl/HTTPie commands, as was any header with an empty value list.

The filter now passes every header except Host through untouched. Added a regression test that fails on main and passes with the fix; spring-restdocs-core checks (tests, checkstyle, spring-javaformat) pass.

The HostHeaderFilter is meant to elide an implicit Host header, but its
allow method never inspected the header name. Any header whose first
value matched the request URI's host - such as X-Forwarded-Host on a
request to the same host - was silently dropped from the generated curl
and HTTPie commands, as was any header with an empty value list.

Fixes spring-projectsgh-1053

Signed-off-by: seonghun lee <harrisleesh@gmail.com>
@wilkinsona wilkinsona changed the title Only filter the Host header in CLI snippets' host header filter Request headers whose value matches the request URI host are dropped from curl and HTTPie snippets Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Request headers whose value matches the request URI host are dropped from curl and HTTPie snippets

2 participants