Skip to content

Setting default charset in StringHttpMessageConverter [SPR-7904] #12559

@spring-projects-issues

Description

@spring-projects-issues

Thomas Ziem opened SPR-7904 and commented

Currently, StringHttpMessageConverter uses ISO-8859-1 as default charset for reading and writing:

public static final Charset DEFAULT_CHARSET = Charset.forName("ISO-8859-1");
protected String readInternal(Class clazz, HttpInputMessage inputMessage) throws IOException {
    MediaType contentType = inputMessage.getHeaders().getContentType();
    Charset charset = contentType.getCharSet() != null ? contentType.getCharSet() : DEFAULT_CHARSET;
    return FileCopyUtils.copyToString(new InputStreamReader(inputMessage.getBody(), charset));
}

It would be nice if it could be configured from outside.


Affects: 3.0.5

Issue Links:

Backported to: 3.1.2

3 votes, 1 watchers

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)status: backportedAn issue that has been backported to maintenance branchesstatus: duplicateA duplicate of another issuetype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions