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

The Netty client may treat a Content-Length header as an indicator to decode body for GET #9489

Closed
artembilan opened this issue Sep 18, 2024 · 0 comments

Comments

@artembilan
Copy link
Member

More info on StackOverflow: https://stackoverflow.com/questions/78989281/spring-integration-webflux-fails-for-every-other-calls.

Fix the AbstractHttpRequestExecutingMessageHandler to remove a Content-Length when:

		if (!shouldIncludeRequestBody(httpMethod)) {
			return new HttpEntity<>(httpHeaders);
		}

The workaround is to remove this header before calling WebFlux outbound channel adapter:

.headerFilter("Content-Length")
@artembilan artembilan added this to the 6.4.0-RC1 milestone Sep 18, 2024
spring-builds pushed a commit that referenced this issue Sep 18, 2024
Fixes: #9489
Issue link: #9489

If request message has a `Content-Length` HTTP, it is still mapped to the target HTTP request
even if that one is indicated as "no-body" (`GET`, `HEAD`, `TRACE`).
In this case Netty fails to decode such a missed body with error:
```
java.lang.IllegalArgumentException: text is empty (possibly HTTP/0.9)), version: HTTP/1.0
```

* Since `Content-Length` is not supposed to be supported for those methods,
remove it altogether from the HTTP request headers
* Add nullability API into the `org.springframework.integration.http.outbound`
* Check received HTTP request on the server side that it does not have such a header for `GET`

(cherry picked from commit 891dca7)
spring-builds pushed a commit that referenced this issue Sep 18, 2024
Fixes: #9489
Issue link: #9489

If request message has a `Content-Length` HTTP, it is still mapped to the target HTTP request
even if that one is indicated as "no-body" (`GET`, `HEAD`, `TRACE`).
In this case Netty fails to decode such a missed body with error:
```
java.lang.IllegalArgumentException: text is empty (possibly HTTP/0.9)), version: HTTP/1.0
```

* Since `Content-Length` is not supposed to be supported for those methods,
remove it altogether from the HTTP request headers
* Add nullability API into the `org.springframework.integration.http.outbound`
* Check received HTTP request on the server side that it does not have such a header for `GET`

(cherry picked from commit 891dca7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants