return sendRequest(request, href, bodies);
}
private Sequence sendRequest(final NodeValue request, final String href, final Sequence bodies) throws XPathException {
HttpRequest req = null;
try {
final org.expath.httpclient.model.Sequence b = new EXistSequence(bodies, getContext());
final Element r = new EXistElement(request, getContext());
final RequestParser parser = new RequestParser();
req = parser.parse(r, b, href);
// override anyway it href exists
if (href != null && ! "".equals(href) ) {
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("Href is not valid: " + req != null ? req.getHref() : "" + ". " + ex.getMessage(), ex);
} catch(final HttpClientException hce) {
throw new XPathException(hce.getMessage(), hce);
}
}