mirror of
https://github.com/square/okhttp.git
synced 2025-08-01 16:06:56 +03:00
Use automatic-resource-management blocks.
This commit is contained in:
@ -251,20 +251,14 @@ public final class HttpLoggingInterceptor implements Interceptor {
|
||||
} else {
|
||||
BufferedSource source = responseBody.source();
|
||||
source.request(Long.MAX_VALUE); // Buffer the entire body.
|
||||
Buffer buffer = source.buffer();
|
||||
Buffer buffer = source.getBuffer();
|
||||
|
||||
Long gzippedLength = null;
|
||||
if ("gzip".equalsIgnoreCase(headers.get("Content-Encoding"))) {
|
||||
gzippedLength = buffer.size();
|
||||
GzipSource gzippedResponseBody = null;
|
||||
try {
|
||||
gzippedResponseBody = new GzipSource(buffer.clone());
|
||||
try (GzipSource gzippedResponseBody = new GzipSource(buffer.clone())) {
|
||||
buffer = new Buffer();
|
||||
buffer.writeAll(gzippedResponseBody);
|
||||
} finally {
|
||||
if (gzippedResponseBody != null) {
|
||||
gzippedResponseBody.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user