Fall back on UTF-8 charset in WebClientResponseException

Instead of ISO-8859-1, consistently with the change done
in RestClientResponseException.

Closes gh-31072
This commit is contained in:
Sébastien Deleuze 2023-10-19 12:58:09 +02:00
parent 9eac9a1831
commit c6b86af78b
1 changed files with 3 additions and 2 deletions

View File

@ -35,6 +35,7 @@ import org.springframework.util.Assert;
* Exceptions that contain actual HTTP response data. * Exceptions that contain actual HTTP response data.
* *
* @author Arjen Poutsma * @author Arjen Poutsma
* @author Sebastien Deleuze
* @since 5.0 * @since 5.0
*/ */
@SuppressWarnings("RedundantSuppression") @SuppressWarnings("RedundantSuppression")
@ -202,11 +203,11 @@ public class WebClientResponseException extends WebClientException {
/** /**
* Return the response content as a String using the charset of media type * Return the response content as a String using the charset of media type
* for the response, if available, or otherwise falling back on * for the response, if available, or otherwise falling back on
* {@literal ISO-8859-1}. Use {@link #getResponseBodyAsString(Charset)} if * {@literal UTF-8}. Use {@link #getResponseBodyAsString(Charset)} if
* you want to fall back on a different, default charset. * you want to fall back on a different, default charset.
*/ */
public String getResponseBodyAsString() { public String getResponseBodyAsString() {
return getResponseBodyAsString(StandardCharsets.ISO_8859_1); return getResponseBodyAsString(StandardCharsets.UTF_8);
} }
/** /**