The routing-helper.xqyset-content-type helper function maps formats to mimetypes, and if it does not recognise the format, it sets the content type to that format. The format is set in router.xqy, which comes from the file extension in the routes XML in roxy/config/defaults.xqy.
This means that unsupported formats have the file extension as the content type, not their associated mimetype. This includes controllers with a txt extension, as text is mapped, but txt is not.
What are the steps to reproduce the problem?
Create a controller returning an unsupported format (e.g. zip, svg, or txt).
Call the controller with that unsupported format extension (e.g. /foo/bar.zip).
Inspect the returned content-type header (e.g. in the Network tab of a web browser's developer tools). This can also make Firefox report "XML Parsing Error: not well-formed" when handling those files via AJAX/jquery.
Thoughts/comments:
The name set-content-type is misleading, it is really set-format.
It would be useful if the format/file extension to content type could use the MarkLogic mimetype data. This could replace the hand-coded if/else format mapping in set-content-type. Alternatively, the config:ROXY-OPTIONS formats should be set with a similar list of extensions to mimetypes covering common formats.
If the format is not recognised, it should throw an error. This will allow the developers to add the format, instead of the server sending the wrong context type creating a silent, difficult to debug error.
Tech Specs
Which Operating System are you using?
Windows 10
Which version of MarkLogic are you using?
8.0-6.3
Which version of Roxy are you using (see version.txt)?
The issue
Short description of the problem:
The
routing-helper.xqy
set-content-type
helper function maps formats to mimetypes, and if it does not recognise the format, it sets the content type to that format. The format is set inrouter.xqy
, which comes from the file extension in the routes XML inroxy/config/defaults.xqy
.This means that unsupported formats have the file extension as the content type, not their associated mimetype. This includes controllers with a
txt
extension, astext
is mapped, buttxt
is not.What are the steps to reproduce the problem?
zip
,svg
, ortxt
)./foo/bar.zip
).Thoughts/comments:
The name
set-content-type
is misleading, it is reallyset-format
.It would be useful if the format/file extension to content type could use the MarkLogic mimetype data. This could replace the hand-coded if/else format mapping in
set-content-type
. Alternatively, theconfig:ROXY-OPTIONS
formats should be set with a similar list of extensions to mimetypes covering common formats.If the format is not recognised, it should throw an error. This will allow the developers to add the format, instead of the server sending the wrong context type creating a silent, difficult to debug error.
Tech Specs
Which Operating System are you using?
Windows 10
Which version of MarkLogic are you using?
8.0-6.3
Which version of Roxy are you using (see version.txt)?
1.7.4