Skip to content

Commit 4721cd4

Browse files
marmoureadamretter
authored andcommitted
[bugfix] writeResultJSON Ignores media types settings.
1 parent 016695f commit 4721cd4

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

exist-core/src/main/java/org/exist/http/RESTServer.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2313,6 +2313,19 @@ private void writeResultJSON(final HttpServletResponse response,
23132313
int start, final Properties outputProperties, final boolean wrap, final long compilationTime, final long executionTime)
23142314
throws BadRequestException {
23152315

2316+
// set output headers
2317+
final String encoding = outputProperties.getProperty(OutputKeys.ENCODING);
2318+
if (!response.containsHeader("Content-Type")) {
2319+
String mimeType = outputProperties.getProperty(OutputKeys.MEDIA_TYPE);
2320+
if (mimeType != null) {
2321+
final int semicolon = mimeType.indexOf(';');
2322+
if (semicolon != Constants.STRING_NOT_FOUND) {
2323+
mimeType = mimeType.substring(0, semicolon);
2324+
}
2325+
response.setContentType(mimeType + "; charset=" + encoding);
2326+
}
2327+
}
2328+
23162329
// calculate number of results to return
23172330
final int rlen = results.getItemCount();
23182331
if (!results.isEmpty()) {

0 commit comments

Comments
 (0)