EncoderHttpMessageWriter adds a Content-Type header even if there's no body #32620
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
status: superseded
An issue that has been superseded by another
Uh oh!
There was an error while loading. Please reload this page.
I was examining this Spring Cloud Gateway issue and discovered that its resolution is blocked by the fact that
org.springframework.http.codec.EncoderHttpMessageWriter
adds a defaultContent-Type
header anyway, regardless of whether the bodyPublisher
is empty or not. Here's an MRETo better match the original issue, I used
org.springframework.cloud.gateway.filter.factory.rewrite.CachedBodyOutputMessage
, but I believe it doesn't really matter. You can replace it with e.g.org.springframework.mock.http.client.reactive.MockClientHttpRequest
, and it will still be reproducibleThe problem is
updateContentType(..)
which sets aContent-Type
headerSpring Cloud Gateway currently uses Spring Web 6.1.5
You may assign me to this issue if you want. I wrote a straightforward fix and added an extra test (will formally submit a PR soon)
The text was updated successfully, but these errors were encountered: