Skip to content

Content-Length header is not updated when body is modified using ClientHttpRequestInterceptor #33872

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

Closed
ceremo opened this issue Nov 12, 2024 · 1 comment
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: duplicate A duplicate of another issue

Comments

@ceremo
Copy link

ceremo commented Nov 12, 2024

Hi,

Since this change, a RestTemplate with a custom interceptor that modifies the body content, the Content-Lenght is not updated, so initial value is sent.
The Content-Length header sent is resolved from the entity included in the request (ClassicHttpRequest), finally is added to the final request in org.apache.hc.core5.http.protocol.RequestContent. The request entity is previously configured in org.springframework.http.client.HttpComponentsClientHttpRequest, this processes the headers discarding the Content-Length from the httpRequest, but in the entity is included, is that correct?

Before that change, I did not have to worry about updating the Content-Length value, so there is a behaviour difference in the latest versions, is this a bug or do I have to update the Content-Length header in the same interceptor where is body content modified?

Thanks for your time.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Nov 12, 2024
@bclozel
Copy link
Member

bclozel commented Nov 12, 2024

Thanks for raising this.
This has been fixed in #33459 already, but only for the upcoming 6.2 release. We did not apply the fix on the existing maintenance branches because it was too late in the maintenance cycle for such a behavior change.

Luckily the release is scheduled for Thursday and Spring Boot 3.4.0 will follow next week.

@bclozel bclozel closed this as not planned Won't fix, can't repro, duplicate, stale Nov 12, 2024
@bclozel bclozel added status: duplicate A duplicate of another issue in: web Issues in web modules (web, webmvc, webflux, websocket) and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Nov 12, 2024
@bclozel bclozel self-assigned this Nov 12, 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) status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants