|
@@ -5,6 +5,8 @@ import okhttp3.*;
|
|
|
import okio.Buffer;
|
|
|
import okio.BufferedSource;
|
|
|
import okio.GzipSource;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.nio.charset.Charset;
|
|
@@ -12,6 +14,8 @@ import java.nio.charset.StandardCharsets;
|
|
|
|
|
|
public class ErrorDecodeInterceptor implements Interceptor {
|
|
|
|
|
|
+ public static final Logger log = LoggerFactory.getLogger(ErrorDecodeInterceptor.class);
|
|
|
+
|
|
|
public static final String GZIP = "gzip";
|
|
|
|
|
|
public static final String CONTENT_ENCODING = "Content-Encoding";
|
|
@@ -44,7 +48,6 @@ public class ErrorDecodeInterceptor implements Interceptor {
|
|
|
if (responseBody == null) {
|
|
|
return null;
|
|
|
}
|
|
|
- long contentLength = responseBody.contentLength();
|
|
|
|
|
|
BufferedSource source = responseBody.source();
|
|
|
// Buffer the entire body.
|
|
@@ -62,14 +65,9 @@ public class ErrorDecodeInterceptor implements Interceptor {
|
|
|
if (contentType != null) {
|
|
|
charset = contentType.charset(StandardCharsets.UTF_8);
|
|
|
}
|
|
|
-
|
|
|
- if (contentLength > 0) {
|
|
|
- return buffer.clone().readString(charset);
|
|
|
- } else {
|
|
|
- return null;
|
|
|
- }
|
|
|
+ return buffer.clone().readString(charset);
|
|
|
} catch (Exception e) {
|
|
|
- //throw new RuntimeException(e);
|
|
|
+ log.error("Retrofit response decode error", e);
|
|
|
return null;
|
|
|
}
|
|
|
}
|