spring-cloud / spring-cloud/spring-cloud-gateway
FormFilter does not adjust Content-Length header
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 4.9k
- Forks
- 3.5k
- Avg merge
- 20h 57m
- Merged PRs (30d)
- 8
Description
Describe the bug
FormFilter can recreate produce body bigger than original but Content-Length header is not changed.
Any other processing may fail because it may read body up to Content-Length trimming it in the process.
Sample
Example is exlamation mark character.
When sending x-www-form-urlencoded form a browser it will not encode "!" into %21.
It will count this character as 1 byte
However FormFilter will encode the character here increasing the output by 2 bytes
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in spring-cloud-gateway-server-webmvc/src/main/java/org/springframework/cloud/gateway/server/mvc/filter/FormFilter.java around the linked line where the form body is recreated. Reproduce the x-www-form-urlencoded case with an exclamation mark and verify that the Content-Length header matches the regenerated body length. Done means downstream processing can read the complete body without truncation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100