Skip to content

HEAD response has "Content-Length: 0" for @RestController @GetMapping methods [SPR-15261] #19826

Closed
@spring-projects-issues

Description

@spring-projects-issues

David Goblirsch opened SPR-15261 and commented

In response to HEAD, now handled by Spring for @GetMapping methods as of 4.3+, the HTTP spec says that it "should" include the same headers that GET would include, except that four header parameters are considered "optional". Content-Length is one of these optional headers for HEAD requests. BUT when it is included, it is supposed to have the same value as it would have been for GET, i.e., the length of the response body. My @RestController @GetMapping methods return the correct non-zero value for GET requests but are setting Content-Length: 0 for HEAD requests.

This is using Spring 4.3.6 on both JBoss 6.1 (yes, very old) and WildFly 10.1.


Affects: 4.3.6

Reference URL: http://stackoverflow.com/questions/27868314/avoiding-content-length-in-head-response

Issue Links:

Referenced from: commits b732251, 45b27a8

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