Skip to content

Commit 122dcb7

Browse files
committed
Merge pull request #401 from jekh/fix-missing-mime-type
Fix missing mimeType in HAR
2 parents c68d0af + d250e2a commit 122dcb7

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

browsermob-core-littleproxy/src/main/java/net/lightbody/bmp/filters/HarCaptureFilter.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,10 @@ protected void captureResponse(HttpResponse httpResponse) {
523523

524524
protected void captureResponseMimeType(HttpResponse httpResponse) {
525525
String contentType = HttpHeaders.getHeader(httpResponse, HttpHeaders.Names.CONTENT_TYPE);
526-
harEntry.getResponse().getContent().setMimeType(contentType);
526+
// don't set the mimeType to null, since mimeType is a required field
527+
if (contentType != null) {
528+
harEntry.getResponse().getContent().setMimeType(contentType);
529+
}
527530
}
528531

529532
protected void captureResponseCookies(HttpResponse httpResponse) {

browsermob-core/src/main/java/net/lightbody/bmp/core/har/HarContent.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
public class HarContent {
77
private volatile long size;
88
private volatile Long compression;
9+
10+
// 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
11+
@JsonInclude(JsonInclude.Include.ALWAYS)
912
private volatile String mimeType = "";
13+
1014
private volatile String text;
1115
private volatile String encoding;
1216
private volatile String comment = "";

0 commit comments

Comments
 (0)