Skip to content

Commit 3839de6

Browse files
committed
Added a fix for mime type parsing
1 parent 939065e commit 3839de6

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/main/java/org/javawebstack/http/router/util/HeaderValue.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
public class HeaderValue {
77

8-
final String value;
9-
final Map<String, String> directives = new HashMap<>();
8+
private final String value;
9+
private final Map<String, String> directives = new HashMap<>();
1010

1111
public HeaderValue(String source) {
1212
String[] spl = source.split("; ");

src/main/java/org/javawebstack/http/router/util/MimeType.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ public static MimeType byExtension(String extension) {
5757
}
5858

5959
public static MimeType byMimeType(String mimeType) {
60+
if(mimeType == null)
61+
return null;
62+
if(mimeType.contains(";"))
63+
mimeType = new HeaderValue(mimeType).getValue();
6064
for (MimeType type : values()) {
6165
if (type.mimeTypes.contains(mimeType)) {
6266
return type;

0 commit comments

Comments
 (0)