Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update HttpHeaders.setHost() to actually remove the Host header #33716

Conversation

bivo
Copy link
Contributor

@bivo bivo commented Oct 16, 2024

This PR fixes a bug in org.springframework.http.HttpHeaders class.
It was not possible to delete/clear the Host header before this fix.

This bug was first introduced in this commit (in 2018): 5bbbc82#diff-e2d6218e6585f8b7e32682f6f8f7aed22dbd76d862ec92e86e0902243889556aR1020

After that commit, the deletion logic line in setHost() method started to look like this: remove(HOST, null)
Although for all other methods/headers it looks like this: remove(CONTENT_TYPE), remove(ETAG), etc.

And for setHost() method it also should be the same: remove(HOST)

I've also added a test for this case. Feel free to rollback my 1-line fix in HttpHeaders and check that Host header is not cleared indeed.

@pivotal-cla
Copy link

@bivo Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@pivotal-cla
Copy link

@bivo Thank you for signing the Contributor License Agreement!

@bivo bivo force-pushed the bugfix/set-host-method-does-not-delete-host branch from 21e9457 to 6398b1a Compare October 16, 2024 09:02
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Oct 16, 2024
@bivo bivo marked this pull request as ready for review October 16, 2024 09:16
@rstoyanchev rstoyanchev added the in: web Issues in web modules (web, webmvc, webflux, websocket) label Oct 22, 2024
@rstoyanchev rstoyanchev self-assigned this Oct 22, 2024
@rstoyanchev rstoyanchev added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Oct 22, 2024
@rstoyanchev rstoyanchev added this to the 6.2.0-RC3 milestone Oct 22, 2024
@rstoyanchev rstoyanchev changed the title Fix the issue with HttpHeaders.setHost() method not deleting the host Update HttpHeaders.setHost() to actually remove the Host header Oct 22, 2024
rstoyanchev pushed a commit that referenced this pull request Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants