File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
spring-web/src/main/java/org/springframework/web/client Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -99,11 +99,22 @@ public byte[] getResponseBodyAsByteArray() {
99
99
}
100
100
101
101
/**
102
- * Return the response body as a string.
102
+ * Return the response body converted to String. The charset used is that
103
+ * of the response "Content-Type" or otherwise {@code "UTF-8"}.
103
104
*/
104
105
public String getResponseBodyAsString () {
106
+ return getResponseBodyAsString (DEFAULT_CHARSET );
107
+ }
108
+
109
+ /**
110
+ * Return the response body converted to String. The charset used is that
111
+ * of the response "Content-Type" or otherwise the one given.
112
+ * @param fallbackCharset the charset to use on if the response doesn't specify.
113
+ * @since 5.1.11
114
+ */
115
+ public String getResponseBodyAsString (Charset fallbackCharset ) {
105
116
if (this .responseCharset == null ) {
106
- return new String (this .responseBody , DEFAULT_CHARSET );
117
+ return new String (this .responseBody , fallbackCharset );
107
118
}
108
119
try {
109
120
return new String (this .responseBody , this .responseCharset );
You can’t perform that action at this time.
0 commit comments