Skip to content

HTTP headers returned as part of ResponseEntity(MultiValueMap<String, String> headers, HttpStatus statusCode) are ignored when using this constructor [SPR-7381] #12039

@spring-projects-issues

Description

@spring-projects-issues

Florian Rampp opened SPR-7381 and commented

If a controller method returns a ResponseEntity, and this entity is created with the constructor ResponseEntity(MultiValueMap<String, String> headers, HttpStatus statusCode) the passed headers are ignored and do not appear in the resulting HTTP response.

I suppose that the reason for this is an error in the class AnnotationMethodHandlerAdapter, line 916:
if (body != null) {
writeWithMessageConverters(body, inputMessage, outputMessage);
}

If the body of the response entity is null, the message is not written.

If I use the constructor ResponseEntity(T body, MultiValueMap<String, String> headers, HttpStatus statusCode), the headers appear as expected.


Affects: 3.0.3

Referenced from: commits c24ffc9

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions