-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
[Gateway MVC] Transfer-Encoding added to GET/HEAD requests, causing some WAF errors #3325
Labels
Milestone
Comments
PRs welcome |
benba
added a commit
to benba/spring-cloud-gateway
that referenced
this issue
Apr 22, 2024
This avoids to have a "Transfer-Encoding: chunked" with an empty body if downstream exchanges in HTTP 1.1 Fixes spring-cloudgh-3325
benba
added a commit
to benba/spring-cloud-gateway
that referenced
this issue
Apr 22, 2024
This avoids to have a "Transfer-Encoding: chunked" with an empty body if downstream exchanges are negociated in HTTP 1.1 Fixes spring-cloudgh-3325
benba
added a commit
to benba/spring-cloud-gateway
that referenced
this issue
Apr 22, 2024
This avoids to have a "Transfer-Encoding: chunked" with an empty body if downstream exchanges are negotiated in HTTP 1.1 Fixes spring-cloudgh-3325
benba
added a commit
to benba/spring-cloud-gateway
that referenced
this issue
Apr 23, 2024
This avoids to have a "Transfer-Encoding: chunked" with an empty body if downstream exchanges are negotiated in HTTP 1.1 Fixes spring-cloudgh-3325
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using the
Jdk HttpClient
, when no body is present in aGET
orHEAD
request, and that the downstream server only supportsHTTP 1.1
:a
Transfer-Encoding: chunked
will be added to the downstream request, causing some WAF to reject it (see "Body in GET or HEAD requests" in BIG-IP ASM HTTP protocol compliance for example).The reason seems to be a combination of the issue describe in GH-3308 that causes
HTTP 1.1
exchange to be always performed inchunked
mode, and the fact that the body is always set in RestClientProxyExchange.This will cause this JdkClientHttpRequest check to think that there is a body (since body is not null and upstream
Content-Length: 0
was removed if present) and will cause the addition of theTransfer-Encoding: chunked
header later.As a workaround I've implemented this fix
isBodyPresent(request)
is simply checking thatrequest.getServerRequest().servletRequest().getInputStream().available() > 0
(using upstreamContent-Length
orTransfer-Encoding
would not work ifserver.http2.enabled=true
).I can submit a PR if you feel that the fix is relevant.
The text was updated successfully, but these errors were encountered: