Skip to content

Commit

Permalink
Merge pull request #109 from Meesho/fix-har-response-bug
Browse files Browse the repository at this point in the history
Generate a default empty content object in null response body cases
  • Loading branch information
vibin authored May 7, 2024
2 parents 171e197 + ee0e874 commit 07b1f3d
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,18 @@ internal data class Response(
statusText = transaction.responseMessage ?: "",
httpVersion = transaction.protocol ?: "",
headers = transaction.getParsedResponseHeaders()?.map { Header(it) } ?: emptyList(),
content = transaction.responsePayloadSize?.run { Content(transaction) },
content = transaction.responsePayloadSize?.run { Content(transaction) } ?: emptyContent(),
headersSize = transaction.responseHeadersSize ?: 0,
bodySize = transaction.getHarResponseBodySize(),
totalSize = transaction.getResponseTotalSize()
)

companion object {
fun emptyContent(): Content {
return Content(
size = 0,
mimeType = "application/octet-stream",
)
}
}
}

0 comments on commit 07b1f3d

Please sign in to comment.