Hi,
I spend a couple of hours pulling my "hair" before I realized what was going on here.
Question: what happens when I call a RESTXQ function which has a rest:produces('application/xml') annotation but the request does not have a Accept header?
This is what HTTP 1.1 spec[1] says about that:
"If no Accept header field is present, then it is assumed that the client accepts all media types. If an Accept header field is present, and if the server cannot send a response which is acceptable according to the combined Accept field value, then the server SHOULD send a 406 (not acceptable) response."
In fact, what does happen is that you get a 404, and this is caused by the rest:produces annotation. In a REST call you do not always set or have the option to set an appropriate accept header (e.g. HTTP client libraries or when doing doc('http://.....') call from XSLT).
I believe that when no Accept header is present the response should assume that any mediatype is ok. Additionally it would be nice for REST clients if in case the path matches but the content-negotiation fails that a 406 would be returned instead of a 404. The latter is saying the resource does not exist, whereas 406 expresses that the issue is with the media-type but the resource may exist.
Quite possibly the text in the RESTXQ spec has to be modified as well in that case because it currentlly reads (consistent with current behaviour):
"If the %rest:produces annotation is specified, a function will only be invoked if the HTTP Accept header of the request matches one of the given types."
Would it be possible to get this changed? Or is it maybe better to take this up in another forum?
[1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html [2] http://exquery.github.io/exquery/exquery-restxq-specification/restxq-1.0-spe...
--Marc