Hi Giuseppe,
Thanks to Andy’s bug report [1], I believe the encoding issue with non-ASCII characters has been fixed. I’m looking forward to your feedback on the latest snapshot [2].
Best, Christian
[1] https://github.com/BaseXdb/basex/issues/1487 [2] http://files.basex.org/releases/latest/
On Mon, Aug 14, 2017 at 8:55 PM, Andy Bunce bunce.andy@gmail.com wrote:
For me it gives...
<http:response xmlns:http="http://expath.org/ns/http-client" status="400" message="Bad Request"> <http:header name="Server" value="nginx/1.11.5"/> <http:header name="Access-Control-Allow-Origin" value="*"/> <http:header name="Connection" value="keep-alive"/> <http:header name="Content-Length" value="37"/> <http:header name="Date" value="Mon, 14 Aug 2017 18:45:48 GMT"/> <http:header name="Content-Type" value="text/plain"/> <http:body media-type="text/plain"/> </http:response> Required argument 'data' is missing.
I think the below should work, but it does not
let $d:="Děti pojedou k babičce. Už se těší" return http:send-request(<http:request method='POST' href='http://lindat.mff.cuni.cz/services/udpipe/api/process%27%3E <http:body media-type ="application/x-www-form-urlencoded">data={encode-for-uri($d)}&tokenizer&tagger&parser</http:body> </http:request>)
returns:
<http:response xmlns:http="http://expath.org/ns/http-client" status="400" message="Bad Request"> <http:header name="Server" value="nginx/1.11.5"/> <http:header name="Access-Control-Allow-Origin" value="*"/> <http:header name="Connection" value="keep-alive"/> <http:header name="Content-Length" value="113"/> <http:header name="Date" value="Mon, 14 Aug 2017 18:47:32 GMT"/> <http:header name="Content-Type" value="text/plain"/> <http:body media-type="text/plain"/> </http:response> Cannot read input data: The CoNLL-U line 'Děti pojedou k babičce. Už se těší' does not contain 10 columns!
Trying to directly emulate curl
let $target:="http://lindat.mff.cuni.cz/services/udpipe/api/process"
let $data:="Děti pojedou k babičce. Už se těší"
let $req:= <http:request method="POST" xmlns="http://expath.org/ns/http-client%22%3E
<multipart media-type="multipart/form-data"> <header name="Content-Disposition" value='form-data; name="tokenizer"'/> <body media-type="text/plain"/> <header name="Content-Disposition" value='form-data; name="tagger"'/> <body media-type="text/plain"/> <header name="Content-Disposition" value='form-data; name="parser"'/> <body media-type="text/plain"/> <header name="Content-Disposition" value='form-data; name="data"'/> <header name="Content-Transfer-Encoding" value='binary'/> <body media-type="text/plain" /> </multipart> </http:request> return http:send-request($req,$target,("","","",($data)))
This works, except when $data contains non 7bit chars, as here. In this case base64 data appears in place of the correct text.
It appears to be similar to this issue:
https://www.mail-archive.com/basex-talk@mailman.uni-konstanz.de/msg09206.htm...
/Andy
On 14 August 2017 at 19:04, Kendall Shaw kendall.shaw@workday.com wrote:
Can you elaborate on “does not work”? What response do you get.
From: Giuseppe Celano celano@informatik.uni-leipzig.de Date: Monday, August 14, 2017 at 10:43 AM To: Kendall Shaw kendall.shaw@workday.com Cc: BaseX basex-talk@mailman.uni-konstanz.de Subject: Re: [basex-talk] HTTP module
Thanks, Kendall, I tried but it does not work :(
Universität Leipzig Institute of Computer Science, Digital Humanities Augustusplatz 10 04109 Leipzig Deutschland E-mail: celano@informatik.uni-leipzig.de E-mail: giuseppegacelano@gmail.com Web site 1: http://www.dh.uni-leipzig.de/wo/team/ Web site 2: https://sites.google.com/site/giuseppegacelano/
On Aug 14, 2017, at 6:53 PM, Kendall Shaw kendall.shaw@workday.com wrote:
http:send-request(<http:request method='post'
href='http://lindat.mff.cuni.cz/services/udpipe/api/process%27%3E
<http:body media-type ="text/plain">
tokenizer&tagger&parser&data=Děti pojedou k babičce. Už se těší.
</http:body>
</http:request>)