diff --git a/browsermob-core-littleproxy/src/main/java/net/lightbody/bmp/filters/HarCaptureFilter.java b/browsermob-core-littleproxy/src/main/java/net/lightbody/bmp/filters/HarCaptureFilter.java index 5f01694b3..a6a3f0229 100644 --- a/browsermob-core-littleproxy/src/main/java/net/lightbody/bmp/filters/HarCaptureFilter.java +++ b/browsermob-core-littleproxy/src/main/java/net/lightbody/bmp/filters/HarCaptureFilter.java @@ -523,7 +523,10 @@ protected void captureResponse(HttpResponse httpResponse) { protected void captureResponseMimeType(HttpResponse httpResponse) { String contentType = HttpHeaders.getHeader(httpResponse, HttpHeaders.Names.CONTENT_TYPE); - harEntry.getResponse().getContent().setMimeType(contentType); + // don't set the mimeType to null, since mimeType is a required field + if (contentType != null) { + harEntry.getResponse().getContent().setMimeType(contentType); + } } protected void captureResponseCookies(HttpResponse httpResponse) { diff --git a/browsermob-core/src/main/java/net/lightbody/bmp/core/har/HarContent.java b/browsermob-core/src/main/java/net/lightbody/bmp/core/har/HarContent.java index 8bfa7db0b..48b67583e 100644 --- a/browsermob-core/src/main/java/net/lightbody/bmp/core/har/HarContent.java +++ b/browsermob-core/src/main/java/net/lightbody/bmp/core/har/HarContent.java @@ -6,7 +6,11 @@ public class HarContent { private volatile long size; private volatile Long compression; + + // mimeType is required; though it shouldn't be set to null, if it is, it still needs to be included to comply with the HAR spec + @JsonInclude(JsonInclude.Include.ALWAYS) private volatile String mimeType = ""; + private volatile String text; private volatile String encoding; private volatile String comment = "";