Skip to content

Commit

Permalink
Fix issue with OkHttp3
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaslabari committed Feb 23, 2024
1 parent 186108b commit e111d49
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class EmbraceOkHttp3NetworkInterceptor internal constructor(

if (contentLength == null) {
// If we get the body for a server-sent events stream, then we will wait forever
contentLength = getContentLengthFromBody(networkResponse, networkResponse.header(CONTENT_TYPE_HEADER_NAME))
contentLength = getContentLengthFromBody(networkResponse, networkResponse.header(CONTENT_TYPE_HEADER_NAME, null))
}

if (contentLength == null) {
Expand All @@ -80,7 +80,7 @@ public class EmbraceOkHttp3NetworkInterceptor internal constructor(

// If we need to capture the network response body,
if (shouldCaptureNetworkData) {
if (ENCODING_GZIP.equals(networkResponse.header(CONTENT_ENCODING_HEADER_NAME), ignoreCase = true) &&
if (ENCODING_GZIP.equals(networkResponse.header(CONTENT_ENCODING_HEADER_NAME, null), ignoreCase = true) &&
networkResponse.promisesBody()
) {
val body = networkResponse.body
Expand All @@ -90,7 +90,7 @@ public class EmbraceOkHttp3NetworkInterceptor internal constructor(
.removeAll(CONTENT_LENGTH_HEADER_NAME)
.build()
val realResponseBody = RealResponseBody(
networkResponse.header(CONTENT_TYPE_HEADER_NAME),
networkResponse.header(CONTENT_TYPE_HEADER_NAME, null),
-1L,
GzipSource(body.source()).buffer()
)
Expand Down Expand Up @@ -123,7 +123,7 @@ public class EmbraceOkHttp3NetworkInterceptor internal constructor(

private fun getContentLengthFromHeader(networkResponse: Response): Long? {
var contentLength: Long? = null
val contentLengthHeaderValue = networkResponse.header(CONTENT_LENGTH_HEADER_NAME)
val contentLengthHeaderValue = networkResponse.header(CONTENT_LENGTH_HEADER_NAME, null)
if (contentLengthHeaderValue != null) {
try {
contentLength = contentLengthHeaderValue.toLong()
Expand Down

0 comments on commit e111d49

Please sign in to comment.