Skip to content

Update content length after rebuilding form body - #4262

Open
hutiefang76 wants to merge 1 commit into
spring-cloud:mainfrom
hutiefang76:codex/spring-cloud-gateway-3972-content-length
Open

Update content length after rebuilding form body#4262
hutiefang76 wants to merge 1 commit into
spring-cloud:mainfrom
hutiefang76:codex/spring-cloud-gateway-3972-content-length

Conversation

@hutiefang76

Copy link
Copy Markdown

Fixes gh-3972

When FormFilter rebuilds a form body from request parameters, URL encoding can change the byte length. The wrapped request currently continues to expose the original content length, so downstream code may truncate the rebuilt body.

This change:

  • reports the rebuilt byte length through getContentLength() and getContentLengthLong();
  • updates the existing Content-Length header through the string, enumeration, and integer accessors;
  • preserves the absence of the header for requests that did not originally contain it.

Tests cover the ! to %21 length increase and the missing-header case.

Verification:

  • ./mvnw -pl spring-cloud-gateway-server-webmvc -Dtest=FormFilterTests test
  • ./mvnw -pl spring-cloud-gateway-server-webmvc test (215 tests, 0 failures/errors, 2 skipped)

Fixes spring-cloudgh-3972

Signed-off-by: 胡铁芳 <137664623+hutiefang76@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FormFilter does not adjust Content-Length header

2 participants