Skip to content

Commit f376245

Browse files
committed
Use gate.corpora.MimeType parsing
Close #50
1 parent 1b09221 commit f376245

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/main/java/co/zeroae/gate/Utils.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ static String asJson(Map<String, Object> obj) {
3535
}
3636

3737
static String ensureValidRequestContentType(String contentType) throws GateException {
38-
final String rv = contentType.equals("application/json") ? "text/json" : contentType;
39-
if (!DocumentFormat.getSupportedMimeTypes().contains(rv)) {
38+
final MimeType mimeType = DocumentFormat.getMimeTypeForString(
39+
contentType.equals("application/json") ? "text/json" : contentType);
40+
if (mimeType == null) {
4041
throw new GateException(
4142
"Unsupported MIME type " + contentType + " valid options are "
4243
+ Arrays.toString(DocumentFormat.getSupportedMimeTypes()
@@ -46,7 +47,7 @@ static String ensureValidRequestContentType(String contentType) throws GateExcep
4647
.toArray())
4748
);
4849
}
49-
return rv;
50+
return mimeType.toString();
5051
}
5152

5253
static String ensureValidResponseType(String acceptHeader) throws GateException {

0 commit comments

Comments
 (0)