Hello,
I'm trying to do a custom multipart response with basex RESTXQ module.
The Custom Response paragraph of https://docs.basex.org/wiki/RESTXQ%C2%A0 indicates :
Custom responses can be generated in XQuery by returning an |rest:response| element, an |http:response| child node that matches the syntax of the EXPath HTTP Client Module http://expath.org/spec/http-client specification, and optional child nodes that will be serialized as usual.
So, the §4.1 of http://expath.org/spec/http-client%C2%A0%C2%A0 (EXPath HTTP Client Module http://expath.org/spec/http-client) indicates :
<http:response status = integer message = string> (http:header*, (http:multipart | http:body)?) </http:response>
But when I try :
declare %rest:path('media4') function page:testjm4() { rest:response <http:response status="200" message="OK"> <http:header name="Content-Length" value="100"/> <http:body media-type="text"> TEST </http:body> </http:response> </rest:response>};
The answer is irremediably :
Stopped at /root/basex/webapp/test.xqm, 46/39: [basex:restxq] Unexpected node: <http:body xmlns:http="http://expath.org/ns/http-client" media-type="text">
TEST 
</http:body>
Neither hhtp:body or http:multipart element can be placed as a child of http:response, that seems contradictory with the expath.org spec...
Any help would be appreciated...
Thanks o lot!
JM
Using :
BaseX Version 10.7 httpserver : basexhttp Operating System: Ubuntu 18.04.6 LTS Kernel: Linux 4.15.0-197-generic Architecture: x86-64
Hi Jean-Marc,
For the time being, I’m sorry multipart support is only available for requests (multipart/mixed [1], multipart/form-data [2]). Responses are limited to single parts (multipart data has not been considered in the RESTXQ specification).
I have added a clarifying comment to our documentation.
Best, Christian
[1] https://docs.basex.org/wiki/RESTXQ#Multipart_Types [2] https://docs.basex.org/wiki/RESTXQ#HTML_Form_Fields
On Sun, Oct 29, 2023 at 8:21 AM Jean-Marc ANSEL ansel.jm@free.fr wrote:
Hello,
I'm trying to do a custom multipart response with basex RESTXQ module.
The Custom Response paragraph of https://docs.basex.org/wiki/RESTXQ indicates :
Custom responses can be generated in XQuery by returning an |rest:response| element, an |http:response| child node that matches the syntax of the EXPath HTTP Client Module http://expath.org/spec/http-client specification, and optional child nodes that will be serialized as usual.
So, the §4.1 of http://expath.org/spec/http-client (EXPath HTTP Client Module http://expath.org/spec/http-client) indicates :
<http:response status = integer message = string> (http:header*, (http:multipart | http:body)?) </http:response>
But when I try :
declare %rest:path('media4') function page:testjm4() { rest:response <http:response status="200" message="OK"> <http:header name="Content-Length" value="100"/> <http:body media-type="text"> TEST </http:body> </http:response> </rest:response>};
The answer is irremediably :
Stopped at /root/basex/webapp/test.xqm, 46/39: [basex:restxq] Unexpected node: <http:body xmlns:http=" http://expath.org/ns/http-client" media-type="text">
TEST 
</http:body>
Neither hhtp:body or http:multipart element can be placed as a child of http:response, that seems contradictory with the expath.org spec...
Any help would be appreciated...
Thanks o lot!
JM
Using :
BaseX Version 10.7 httpserver : basexhttp Operating System: Ubuntu 18.04.6 LTS Kernel: Linux 4.15.0-197-generic Architecture: x86-64
basex-talk@mailman.uni-konstanz.de