use of org.expath.httpclient.impl.RequestParser in project exist by eXist-db.
the class SendRequestFunction method sendRequest.
private Sequence sendRequest(final NodeValue request, final String href, final Sequence bodies) throws XPathException {
HttpRequest req = null;
try {
final org.expath.tools.model.Sequence b = new EXistSequence(bodies, getContext());
final Element r = new EXistElement(request, getContext());
final RequestParser parser = new RequestParser(r);
req = parser.parse(b, href);
// override anyway it href exists
if (href != null && !href.isEmpty()) {
req.setHref(href);
}
final URI uri = new URI(req.getHref());
final EXistResult result = sendOnce(uri, req, parser);
return result.getResult();
} catch (final URISyntaxException ex) {
throw new XPathException(this, "Href is not valid: " + req != null ? req.getHref() : "" + ". " + ex.getMessage(), ex);
} catch (final HttpClientException hce) {
throw new XPathException(this, hce.getMessage(), hce);
}
}
Aggregations