From ee0e8747c3ca006ff5072472353893fd85c4d40e Mon Sep 17 00:00:00 2001 From: Vibin reddy Date: Mon, 6 May 2024 15:35:46 -0400 Subject: [PATCH] Generate a default empty content object for null responsePayloadSize cases Response content objects are not optional according to the HAR parser included in Chromium: https://source.chromium.org/chromium/chromium/src/+/main:third_party/devtools-frontend/src/front_end/models/har/HARFormat.ts;l=11-18;bpv=0;bpt=1 --- .../chucker/internal/data/har/log/entry/Response.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/library/src/main/kotlin/com/chuckerteam/chucker/internal/data/har/log/entry/Response.kt b/library/src/main/kotlin/com/chuckerteam/chucker/internal/data/har/log/entry/Response.kt index 685c5b45d..736b29563 100644 --- a/library/src/main/kotlin/com/chuckerteam/chucker/internal/data/har/log/entry/Response.kt +++ b/library/src/main/kotlin/com/chuckerteam/chucker/internal/data/har/log/entry/Response.kt @@ -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", + ) + } + } }