Hello,
I have problem with http:send-request. I want to send post method request with form data but I encountered problem with characters encoding.
Example:
Request:
for $x in http:send-request(
<http:request method='post' href='http://localhost:3333%27%3E
<http:header name="User-Agent" value="Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"/>
<http:body media-type='application/x-www-form-urlencoded; charset=UTF-8'>
<![CDATA[start=0&length=100&sort=date_type&page=0&size=100]]>
</http:body>
</http:request>
)[2]/json/data/results/content
return $x
Optimized Query:
util:item-at(http:send-request(element Q{http://expath.org/ns/http-client%7Drequest { (attribute method { ("post") }, attribute href { ("http://localhost:3333") }, element Q{http://expath.org/ns/http-client%7Dheader { (attribute name { ("User-Agent") }, attribute value { ("Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36") }) }, element Q{http://expath.org/ns/http-client%7Dbody { (attribute media-type { ("application/x-www-form-urlencoded; charset=UTF-8") }, "
 start=0&length=100&sort=date_type&page=0&size=100
 ") }) }), 2)/json/data/results/content
Request send:
POST / HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Host: copart.com:3333
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive
Content-Length: 75
start=0&length=100&sort=date_type&page=0&size=100
Payload is not correctly encoded it should be:
start=0&length=100&sort=date_type&page=0&size=100
How can I force function http:send-request to serialize CDATA without escaping ?
Best Regards
Bogdan Bogucki