Skip to content

Avoid update to request "Content-Type" for characterEncoding in ServletServerHttpRequest #36426

@rstoyanchev

Description

@rstoyanchev

ServletServerHttpRequest#getHeaders re-creates the MediaType if ServletRequest#getCharacterEncoding is not null but the request "Content-Type" doesn't have a charset parameter. This is quite common in practice because the former is always true while the latter is common and fully expected, e.g. for "application/json".

We can update methods in ServletRequestHeadersAdapter that access header values (getFirst, get) to add special handling for "Content-Type", appending the charset lazily, and caching the result, also ensuring UTF-8 is not appended to "application/json".

That would allow us to drop the code that re-creates the MediaType, that in turn also triggers the RequestHeaderOverrideWrapper to create an override map.

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions