RESTXQ Custom Multipart Response

Sunday, 29 October 2023 · 2 messages
JA
Jean-Marc ANSEL29 Oct 2023 08:21 #
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">&#xA;TEST &#xA;</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
CG
Christian Grün29 Oct 2023 10:46 #
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
Quoted text · Jean-Marc ANSEL · 63 lines
On Sun, Oct 29, 2023 at 8:21 AM Jean-Marc ANSEL <ansel.jm at 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">&#xA;TEST > &#xA;</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 > >

⚡Generated with XQuery