HttpClient: Fix NullPointerException if response has no content type.

This commit is contained in:
Andreas Schildbach 2018-12-21 14:09:58 +01:00
parent a873801249
commit 27bf5d6c1e

View file

@ -101,7 +101,7 @@ public final class HttpClient {
public Response intercept(final Interceptor.Chain chain) throws IOException {
Response response = chain.proceed(chain.request());
final MediaType originalContentType = response.body().contentType();
if ("text".equalsIgnoreCase(originalContentType.type())
if (originalContentType != null && "text".equalsIgnoreCase(originalContentType.type())
&& "xml".equalsIgnoreCase(originalContentType.subtype())
&& originalContentType.charset() == null) {
final String peek = response.peekBody(64).string();