Skip to content

Truncated HTTP responses [SPR-8867] #13509

@spring-projects-issues

Description

@spring-projects-issues

Harald Wellmann opened SPR-8867 and commented

After upgrading my Spring MVC application from Spring 3.0.6 to 3.1.0.RC1, I'm getting errors from some of my AJAX requests with JSON responses.

With Spring 3.0.6, the Content-Length header was not set. With Spring 3.1.0.RC1 the header is set, but the value does not match the actual length of the JSON string, which causes the truncation.

My controller method returns a HttpEntity where the Content-Type header is set to text/plain;charset=utf-8. The problem seems to be that StringHttpMessageConverter uses the charset from the output message for encoding the content in writeInternal(), but does not use the same character set for computing the length: getContentLength() derives the character set from the MediaType and defaults to iso-8559-1. This is why the Content-Length value is smaller than it should be.


Affects: 3.1 RC1

Issue Links:

Referenced from: commits spring-attic/spring-framework-issues@f9de7ce, spring-attic/spring-framework-issues@1f66876

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