mirror of
https://github.com/square/okhttp.git
synced 2025-11-27 18:21:14 +03:00
Handle UnsupportedCharsetException in HttpLoggingInterceptor
This commit is contained in:
@@ -17,6 +17,7 @@ package okhttp3.logging;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.UnsupportedCharsetException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import okhttp3.Connection;
|
||||
import okhttp3.Headers;
|
||||
@@ -227,7 +228,15 @@ public final class HttpLoggingInterceptor implements Interceptor {
|
||||
Charset charset = UTF8;
|
||||
MediaType contentType = responseBody.contentType();
|
||||
if (contentType != null) {
|
||||
charset = contentType.charset(UTF8);
|
||||
try {
|
||||
charset = contentType.charset(UTF8);
|
||||
} catch (UnsupportedCharsetException e) {
|
||||
logger.log("");
|
||||
logger.log("Couldn't decode the response body; charset is likely malformed.");
|
||||
logger.log("<-- END HTTP");
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
if (contentLength != 0) {
|
||||
|
||||
Reference in New Issue
Block a user