Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

Improve rh:set-content-type mapping of formats/extensions to content types. #857

Open
rhdunn opened this issue Oct 26, 2017 · 0 comments
Open

Comments

@rhdunn
Copy link
Contributor

rhdunn commented Oct 26, 2017

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 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?
  1. Create a controller returning an unsupported format (e.g. zip, svg, or txt).
  2. Call the controller with that unsupported format extension (e.g. /foo/bar.zip).
  3. 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)?

1.7.4

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant