1
0
mirror of https://github.com/square/okhttp.git synced 2025-11-24 18:41:06 +03:00

Cleanup HttpLoggingInterceptor (#4346)

* Use try-with-resources

* Make bodyHasUnknownEncoding() static

* Fix nits in HttpLoggingInterceptorTest

* Revert "Use try-with-resources"

This reverts commit 57dcd61a9e.
This commit is contained in:
Amir Livneh
2018-11-14 23:29:45 -05:00
committed by Jesse Wilson
parent ef34a41d09
commit 1f7e796e6e
2 changed files with 4 additions and 4 deletions

View File

@@ -326,7 +326,7 @@ public final class HttpLoggingInterceptor implements Interceptor {
}
}
private boolean bodyHasUnknownEncoding(Headers headers) {
private static boolean bodyHasUnknownEncoding(Headers headers) {
String contentEncoding = headers.get("Content-Encoding");
return contentEncoding != null
&& !contentEncoding.equalsIgnoreCase("identity")

View File

@@ -59,8 +59,8 @@ public final class HttpLoggingInterceptorTest {
@Rule public final MockWebServer server = new MockWebServer();
private HandshakeCertificates handshakeCertificates = localhost();
private HostnameVerifier hostnameVerifier = new RecordingHostnameVerifier();
private final HandshakeCertificates handshakeCertificates = localhost();
private final HostnameVerifier hostnameVerifier = new RecordingHostnameVerifier();
private OkHttpClient client;
private String host;
private HttpUrl url;
@@ -650,7 +650,7 @@ public final class HttpLoggingInterceptorTest {
.assertNoMoreLogs();
}
@Test public void isPlaintext() throws IOException {
@Test public void isPlaintext() {
assertTrue(HttpLoggingInterceptor.isPlaintext(new Buffer()));
assertTrue(HttpLoggingInterceptor.isPlaintext(new Buffer().writeUtf8("abc")));
assertTrue(HttpLoggingInterceptor.isPlaintext(new Buffer().writeUtf8("new\r\nlines")));