diff --git a/okhttp-logging-interceptor/src/main/kotlin/okhttp3/logging/HttpLoggingInterceptor.kt b/okhttp-logging-interceptor/src/main/kotlin/okhttp3/logging/HttpLoggingInterceptor.kt index e452fb30a79f..7297b41841ce 100644 --- a/okhttp-logging-interceptor/src/main/kotlin/okhttp3/logging/HttpLoggingInterceptor.kt +++ b/okhttp-logging-interceptor/src/main/kotlin/okhttp3/logging/HttpLoggingInterceptor.kt @@ -358,7 +358,8 @@ class HttpLoggingInterceptor private fun bodyHasUnknownEncoding(headers: Headers): Boolean { val contentEncoding = headers["Content-Encoding"] ?: return false return !contentEncoding.equals("identity", ignoreCase = true) && - !contentEncoding.equals("gzip", ignoreCase = true) + !contentEncoding.equals("gzip", ignoreCase = true) && + !contentEncoding.equals("br", ignoreCase = true) } private fun bodyIsStreaming(response: Response): Boolean { diff --git a/okhttp-logging-interceptor/src/test/java/okhttp3/logging/HttpLoggingInterceptorTest.kt b/okhttp-logging-interceptor/src/test/java/okhttp3/logging/HttpLoggingInterceptorTest.kt index 3d3ba66ee478..25c2b207d3af 100644 --- a/okhttp-logging-interceptor/src/test/java/okhttp3/logging/HttpLoggingInterceptorTest.kt +++ b/okhttp-logging-interceptor/src/test/java/okhttp3/logging/HttpLoggingInterceptorTest.kt @@ -661,7 +661,7 @@ class HttpLoggingInterceptorTest { server.enqueue( MockResponse .Builder() // It's invalid to return this if not requested, but the server might anyway - .setHeader("Content-Encoding", "br") + .setHeader("Content-Encoding", "xyz") .setHeader("Content-Type", PLAIN) .body(Buffer().write("iwmASGVsbG8sIEhlbGxvLCBIZWxsbwoD".decodeBase64()!!)) .build(), @@ -676,7 +676,7 @@ class HttpLoggingInterceptorTest { .assertLogMatch(Regex("""User-Agent: okhttp/.+""")) .assertLogEqual("--> END GET") .assertLogMatch(Regex("""<-- 200 OK $url \(\d+ms\)""")) - .assertLogEqual("Content-Encoding: br") + .assertLogEqual("Content-Encoding: xyz") .assertLogEqual("Content-Type: text/plain; charset=utf-8") .assertLogMatch(Regex("""Content-Length: \d+""")) .assertLogEqual("<-- END HTTP (encoded body omitted)") @@ -685,7 +685,7 @@ class HttpLoggingInterceptorTest { .assertLogEqual("--> GET $url") .assertLogEqual("--> END GET") .assertLogMatch(Regex("""<-- 200 OK $url \(\d+ms\)""")) - .assertLogEqual("Content-Encoding: br") + .assertLogEqual("Content-Encoding: xyz") .assertLogEqual("Content-Type: text/plain; charset=utf-8") .assertLogMatch(Regex("""Content-Length: \d+""")) .assertLogEqual("<-- END HTTP (encoded body omitted)")