Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebClientResponseException defaults to ISO-8859-1 #31072

Closed
frasch1712 opened this issue Aug 18, 2023 · 0 comments
Closed

WebClientResponseException defaults to ISO-8859-1 #31072

frasch1712 opened this issue Aug 18, 2023 · 0 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@frasch1712
Copy link

Affects: 5.x, 6.x


The default was changed for RestClientResponseException in #23764

org.springframework.web.reactive.function.client.WebClientResponseException still defaults to ISO-8859-1.

	 * Return the response content as a String using the charset of media type
	 * for the response, if available, or otherwise falling back on
	 * {@literal ISO-8859-1}. Use {@link #getResponseBodyAsString(Charset)} if
	 * you want to fall back on a different, default charset.
	 */
	public String getResponseBodyAsString() {
		return getResponseBodyAsString(StandardCharsets.ISO_8859_1);
	}

Shouldn't this also be changed to UTF-8?

Shouldn't org.springframework.web.reactive.function.client.DefaultClientResponse#createException have UTF-8 as default Charset for Responses of type "application/json"? Currently its null.

Charset charset = headers().contentType().map(MimeType::getCharset).orElse(null);

This could also solve the problem.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Aug 18, 2023
@sdeleuze sdeleuze added the in: web Issues in web modules (web, webmvc, webflux, websocket) label Oct 8, 2023
@sdeleuze sdeleuze self-assigned this Oct 8, 2023
@sdeleuze sdeleuze added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Oct 18, 2023
@sdeleuze sdeleuze added this to the 6.1.0-RC2 milestone Oct 18, 2023
sdeleuze added a commit to sdeleuze/spring-framework that referenced this issue Oct 19, 2023
Instead of ISO-8859-1, consistently with the change done
in RestClientResponseException.

Closes spring-projectsgh-31072
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants