Skip to content

Commit 6ac5da8

Browse files
committed
Add lenient mode to MediaType parser
Users often find it surprising that methods like message.contentType() can throw IllegalArgumentException when the media type is invalid. So this adds a MediaType.parseLeniently() method that tries to recover from invalid media type strings and uses it in such cases. Fixes #83
1 parent 29afed7 commit 6ac5da8

File tree

7 files changed

+286
-85
lines changed

7 files changed

+286
-85
lines changed

src/org/netpreserve/jwarc/GeminiResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public MediaType contentType() {
9999
if (meta.isEmpty()) {
100100
return MediaType.parse("text/gemini; charset=utf-8");
101101
}
102-
return MediaType.parse(meta);
102+
return MediaType.parseLeniently(meta);
103103
} else {
104104
return MediaType.OCTET_STREAM;
105105
}

0 commit comments

Comments
 (0)