Skip to content

EncoderHttpMessageWriter never sets Content-Length [SPR-16542] #21085

Closed
@spring-projects-issues

Description

@spring-projects-issues

Rossen Stoyanchev opened SPR-16542 and commented

Currently only ResourceHttpMessageWriter and FormHttpMessageWriter set the Content-Length header. For any Encoder (String, byte[], ByteBuffer, etc) wrapped with EncoderHttpMessageWriter, there is no mechanism in place to set the Content-Length header, even in cases where a single item is provided synchronously (e.g. WebClient's syncBody, controller returning a String, etc.).

We should be able to set the content length in cases where the input Publisher is a Mono. That would provide parity with HttpMessageConverters, covering all single value cases (synchronous or asynchronous).


Affects: 5.0.4

Issue Links:

Referenced from: commits 2781584

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions