XQuery Function Documentation

Search and Browse

http://exist-db.org/xquery/httpclient

java:org.exist.xquery.modules.httpclient.HTTPClientModule

A module for performing HTTP requests as a client

httpclient:clear-all

httpclient:clear-all() as item()

Clears all persistent state (eg. cookies, credentials, etc.) stored in the current session on the client.

Returns:
item()

httpclient:delete

httpclient:delete($url as xs:anyURI, $persist as xs:boolean, $request-headers as element()?) as item()

Performs a HTTP DELETE request. This method returns the HTTP response encoded as an XML fragment, that looks as follows: <httpclient:response xmlns:httpclient="http://exist-db.org/xquery/httpclient" statusCode="200"><httpclient:headers><httpclient:header name="name" value="value"/>...</httpclient:headers><httpclient:body type="xml|xhtml|text|binary" mimetype="returned content mimetype">body content</httpclient:body></httpclient:response> where XML body content will be returned as a Node, HTML body content will be tidied into an XML compatible form, a body with mime-type of "text/..." will be returned as a URLEncoded string, and any other body content will be returned as xs:base64Binary encoded data.

Parameters:
$url The URL to process
$persist Indicates if the HTTP state (eg. cookies, credentials, etc.) should persist for the life of this xquery
$request-headers? Any HTTP Request Headers to set in the form <headers><header name="" value=""/></headers>
Returns:
item() : the XML body content

httpclient:get

httpclient:get($url as xs:anyURI, $persist as xs:boolean, $request-headers as element()?) as item()

Performs a HTTP GET request. This method returns the HTTP response encoded as an XML fragment, that looks as follows: <httpclient:response xmlns:httpclient="http://exist-db.org/xquery/httpclient" statusCode="200"><httpclient:headers><httpclient:header name="name" value="value"/>...</httpclient:headers><httpclient:body type="xml|xhtml|text|binary" mimetype="returned content mimetype">body content</httpclient:body></httpclient:response> where XML body content will be returned as a Node, HTML body content will be tidied into an XML compatible form, a body with mime-type of "text/..." will be returned as a URLEncoded string, and any other body content will be returned as xs:base64Binary encoded data.

Parameters:
$url The URL to process
$persist Indicates if the HTTP state (eg. cookies, credentials, etc.) should persist for the life of this xquery
$request-headers? Any HTTP Request Headers to set in the form <headers><header name="" value=""/></headers>
Returns:
item() : the XML body content

httpclient:get

httpclient:get($url as xs:anyURI, $persist as xs:boolean, $request-headers as element()?, $parser-options as element()?) as item()

Performs a HTTP GET request. This method returns the HTTP response encoded as an XML fragment, that looks as follows: <httpclient:response xmlns:httpclient="http://exist-db.org/xquery/httpclient" statusCode="200"><httpclient:headers><httpclient:header name="name" value="value"/>...</httpclient:headers><httpclient:body type="xml|xhtml|text|binary" mimetype="returned content mimetype">body content</httpclient:body></httpclient:response> where XML body content will be returned as a Node, HTML body content will be tidied into an XML compatible form, a body with mime-type of "text/..." will be returned as a URLEncoded string, and any other body content will be returned as xs:base64Binary encoded data. When HTML is converted to XML. Features and properties of the parser may be set in the options parameter.

Parameters:
$url The URL to process
$persist Indicates if the HTTP state (eg. cookies, credentials, etc.) should persist for the life of this xquery
$request-headers? Any HTTP Request Headers to set in the form <headers><header name="" value=""/></headers>
$parser-options? Feature and Property options to be passed to the HTML/XML parser in the form <options><feature name="" value="{true|false}"/><property name="" value=""/></options>
Returns:
item() : the XML body content

httpclient:head

httpclient:head($url as xs:anyURI, $persist as xs:boolean, $request-headers as element()?) as item()

Performs a HTTP HEAD request. This method returns the HTTP response encoded as an XML fragment, that looks as follows: <httpclient:response xmlns:httpclient="http://exist-db.org/xquery/httpclient" statusCode="200"><httpclient:headers><httpclient:header name="name" value="value"/>...</httpclient:headers></httpclient:response>

Parameters:
$url The URL to process
$persist Indicates if the HTTP state (eg. cookies, credentials, etc.) should persist for the life of this xquery
$request-headers? Any HTTP Request Headers to set in the form <headers><header name="" value=""/></headers>
Returns:
item() : the XML body content

httpclient:options

httpclient:options($url as xs:anyURI, $persist as xs:boolean, $request-headers as element()?) as item()

Performs a HTTP OPTIONS request. This method returns the HTTP response encoded as an XML fragment, that looks as follows: <httpclient:response xmlns:httpclient="http://exist-db.org/xquery/httpclient" statusCode="200"><httpclient:headers><httpclient:header name="name" value="value"/>...</httpclient:headers></httpclient:response>

Parameters:
$url The URL to process
$persist Indicates if the HTTP state (eg. cookies, credentials, etc.) should persist for the life of this xquery
$request-headers? Any HTTP Request Headers to set in the form <headers><header name="" value=""/></headers>
Returns:
item() : the XML body content

httpclient:post

httpclient:post($url as xs:anyURI, $content as item(), $persist as xs:boolean, $request-headers as element()?) as item()

Performs a HTTP POST request. This method returns the HTTP response encoded as an XML fragment, that looks as follows: <httpclient:response xmlns:httpclient="http://exist-db.org/xquery/httpclient" statusCode="200"><httpclient:headers><httpclient:header name="name" value="value"/>...</httpclient:headers><httpclient:body type="xml|xhtml|text|binary" mimetype="returned content mimetype">body content</httpclient:body></httpclient:response> where XML body content will be returned as a Node, HTML body content will be tidied into an XML compatible form, a body with mime-type of "text/..." will be returned as a URLEncoded string, and any other body content will be returned as xs:base64Binary encoded data.

Parameters:
$url The URL to process
$content The XML POST payload/content. If it is an XML Node it will be serialized, any other type will be atomized into a string.
$persist Indicates if the HTTP state (eg. cookies, credentials, etc.) should persist for the life of this xquery
$request-headers? Any HTTP Request Headers to set in the form <headers><header name="" value=""/></headers>
Returns:
item() : the XML body content

httpclient:post-form

httpclient:post-form($url as xs:anyURI, $content as element(), $persist as xs:boolean, $request-headers as element()?) as item()

Performs a HTTP POST request for a form. This method returns the HTTP response encoded as an XML fragment, that looks as follows: <httpclient:response xmlns:httpclient="http://exist-db.org/xquery/httpclient" statusCode="200"><httpclient:headers><httpclient:header name="name" value="value"/>...</httpclient:headers><httpclient:body type="xml|xhtml|text|binary" mimetype="returned content mimetype">body content</httpclient:body></httpclient:response> where XML body content will be returned as a Node, HTML body content will be tidied into an XML compatible form, a body with mime-type of "text/..." will be returned as a URLEncoded string, and any other body content will be returned as xs:base64Binary encoded data.

Parameters:
$url The URL to process
$content The form data in the format <httpclient:fields><httpclient:field name="" value="" type="string|file"/>...</httpclient:fields>. If the field values will be suitably URLEncoded and sent with the mime type application/x-www-form-urlencoded.
$persist Indicates if the HTTP state (eg. cookies, credentials, etc.) should persist for the life of this xquery
$request-headers? Any HTTP Request Headers to set in the form <headers><header name="" value=""/></headers>
Returns:
item() : the XML body content

httpclient:put

httpclient:put($url as xs:anyURI, $content as item(), $persist as xs:boolean, $request-headers as element()?) as item()

Performs a HTTP PUT request.. This method returns the HTTP response encoded as an XML fragment, that looks as follows: <httpclient:response xmlns:httpclient="http://exist-db.org/xquery/httpclient" statusCode="200"><httpclient:headers><httpclient:header name="name" value="value"/>...</httpclient:headers><httpclient:body type="xml|xhtml|text|binary" mimetype="returned content mimetype">body content</httpclient:body></httpclient:response> where XML body content will be returned as a Node, HTML body content will be tidied into an XML compatible form, a body with mime-type of "text/..." will be returned as a URLEncoded string, and any other body content will be returned as xs:base64Binary encoded data.

Parameters:
$url The URL to process
$content The XML PUT payload/content. If it is an XML Node it will be serialized. If it is a binary stream it pass as it, any other type will be atomized into a string.
$persist Indicates if the HTTP state (eg. cookies, credentials, etc.) should persist for the life of this xquery
$request-headers? Any HTTP Request Headers to set in the form <headers><header name="" value=""/></headers>
Returns:
item() : the XML body content

httpclient:put

httpclient:put($url as xs:anyURI, $content as item(), $persist as xs:boolean, $request-headers as element()?, $indentation as xs:integer) as item()

Performs a HTTP PUT request.. This method returns the HTTP response encoded as an XML fragment, that looks as follows: <httpclient:response xmlns:httpclient="http://exist-db.org/xquery/httpclient" statusCode="200"><httpclient:headers><httpclient:header name="name" value="value"/>...</httpclient:headers><httpclient:body type="xml|xhtml|text|binary" mimetype="returned content mimetype">body content</httpclient:body></httpclient:response> where XML body content will be returned as a Node, HTML body content will be tidied into an XML compatible form, a body with mime-type of "text/..." will be returned as a URLEncoded string, and any other body content will be returned as xs:base64Binary encoded data.

Parameters:
$url The URL to process
$content The XML PUT payload/content. If it is an XML Node it will be serialized. If it is a binary stream it pass as it, any other type will be atomized into a string.
$persist Indicates if the HTTP state (eg. cookies, credentials, etc.) should persist for the life of this xquery
$request-headers? Any HTTP Request Headers to set in the form <headers><header name="" value=""/></headers>
$indentation Indentation level. If this parameter is added, then the XML being put will be serailazed with indentation and the number is the number of characters for each level of indentation. If this parameter is not include, then the XML is serialized to one line of text.
Returns:
item() : the XML body content

httpclient:set-parser-options

httpclient:set-parser-options($parser-options as element()?) as item()

Sets default options for the HTML parser for all subsequent requests in this session

Parameters:
$parser-options? Feature and Property options to be passed to the HTML/XML parser in the form <options><feature name="" value="{true|false}"/><property name="" value=""/></options>
Returns:
item()