XQuery Function Documentation

Search and Browse

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

java:org.exist.xquery.functions.request.RequestModule

A module for dealing with HTTP requests.

request:attribute-names

request:attribute-names() as xs:string*

Returns the names of all request attributes in the current request.

Returns:
xs:string* : the names of all attributes attached to the current request

request:exists

request:exists() as xs:boolean

Returns whether a request object exists.

Returns:
xs:boolean : true if the request object exists

request:get-attribute

request:get-attribute($attribute-name as xs:string) as item()*

Returns the string value of the request attribute specified in the argument or the empty sequence if no such attribute exists. The attribute value should be a string.

Parameters:
$attribute-name The name of the attribute
Returns:
item()* : the string value of the requested attribute

request:get-context-path

request:get-context-path() as xs:string

Returns the context path of the current request, i.e. the portion of the request URI that indicates the context of the request.

Returns:
xs:string : the context path of the current request

request:get-data

request:get-data() as item()?

Returns the content of a POST request. If the HTTP Content-Type header in the request identifies it as a binary document, then xs:base64Binary is returned. If its not a binary document, we attempt to parse it as XML and return a document-node(). If its not a binary or XML document, any other data type is returned as an xs:string representation or an empty sequence if there is no data to be read.

Returns:
item()? : the content of a POST request

request:get-effective-uri

request:get-effective-uri() as xs:anyURI

Returns the URI of the current request. If the request was forwarded via URL rewriting, the function returns the effective, rewritten URI, not the original URI which was received from the client.

Returns:
xs:anyURI : the URI of the request

request:get-header

request:get-header($header-name as xs:string) as xs:string?

Returns the HTTP request header identified by $header-name. The list of all headers included in the HTTP request are available through the request:get-header-names function.

Parameters:
$header-name The HTTP request header name
Returns:
xs:string? : the HTTP request header value

request:get-header-names

request:get-header-names() as xs:string*

Returns a sequence containing the names of all headers passed in the current request

Returns:
xs:string* : a sequence containing the names of all headers passed in the current request

request:get-hostname

request:get-hostname() as xs:string

Returns the hostname of the current request.

Returns:
xs:string : the hostname of the current request

request:get-method

request:get-method() as xs:string

Returns the HTTP method of the current request.

Returns:
xs:string : the HTTP method of the current request

request:get-parameter

request:get-parameter($name as xs:string, $default-value as item()*) as xs:string*

Returns the HTTP request parameter identified by $name. If the parameter could not be found, the default value is returned instead. Note: this function will not try to expand predefined entities like & or <, so a & passed through a parameter will indeed be treated as an & character.

Parameters:
$name The parameter name
$default-value* The default value if the parameter does not exist
Returns:
xs:string* : a sequence of parameter values

request:get-parameter

request:get-parameter($name as xs:string, $default-value as item()*, $failonerror as xs:boolean*) as xs:string*

Returns the HTTP request parameter identified by $name. If the parameter could not be found, the default value is returned instead. Note: this function will not try to expand predefined entities like & or <, so a & passed through a parameter will indeed be treated as an & character.

Parameters:
$name The parameter name
$default-value* The default value if the parameter does not exist
$failonerror* The fail on error flag. If the value is set to false, then the function will not fail if there is no request in scope.
Returns:
xs:string* : a sequence of parameter values

request:get-parameter-names

request:get-parameter-names() as xs:string*

Returns a sequence containing the names of all parameters passed in the current request

Returns:
xs:string* : the sequence containing the names of all parameters

request:get-path-info

request:get-path-info() as xs:string

Returns any extra path information associated with the URL the client sent when it made this request. For example an xquery GET or POST to /some/path/myfile.xq/extra/path will return /extra/path when myfile.xq is executed.

Returns:
xs:string : the request path information

request:get-query-string

request:get-query-string() as xs:string?

Returns the full query string passed to the servlet (without the initial question mark).

Returns:
xs:string? : the query string

request:get-remote-addr

request:get-remote-addr() as xs:string

Returns the IP address of the client machine that made the current request, as a string.

Returns:
xs:string : the IP address

request:get-remote-host

request:get-remote-host() as xs:string

Returns the fully qualified name of the client or the last proxy that sent the current request.

Returns:
xs:string : the host name

request:get-remote-port

request:get-remote-port() as xs:integer

Returns the Internet Protocol (IP) source port of the client or last proxy that sent the current request.

Returns:
xs:integer : the IP port number

request:get-scheme

request:get-scheme() as xs:string

Returns the name of the scheme used in the current request, for example, http, https, or ftp.

Returns:
xs:string : the scheme of the current request

request:get-server-name

request:get-server-name() as xs:string

Returns the server nodename of the current request.

Returns:
xs:string : the server host name of the current request

request:get-server-port

request:get-server-port() as xs:integer

Returns the server port of the current request.

Returns:
xs:integer : the server port of the current request

request:get-servlet-path

request:get-servlet-path() as xs:string

Returns the servlet path of the current request, i.e. the portion of the request URI that points to the servlet which is handling the request. For example an xquery GET or POST to /some/path/myfile.xq/extra/path will return /some/path/myfile.xq when myfile.xq is executed.

Returns:
xs:string : the servlet path of the current request

request:get-uploaded-file-data

request:get-uploaded-file-data($upload-param-name as xs:string) as xs:base64Binary*

Retrieve the base64 encoded data where the file part of a multi-part request has been stored. Returns the empty sequence if the request is not a multi-part request or the parameter name does not point to a file part.

Parameters:
$upload-param-name The parameter name
Returns:
xs:base64Binary* : the base64 encoded data from the uploaded file

request:get-uploaded-file-name

request:get-uploaded-file-name($upload-param-name as xs:string) as xs:string*

Retrieve the file name of an uploaded file from a multi-part request. This returns the file name of the file on the client (without path). Returns the empty sequence if the request is not a multi-part request or the parameter name does not point to a file part.

Parameters:
$upload-param-name The parameter name
Returns:
xs:string* : the file name of the uploaded files

request:get-uploaded-file-size

request:get-uploaded-file-size($upload-param-name as xs:string) as xs:double*

Retrieve the size of an uploaded file from a multi-part request. This returns the size of the file in bytes. Returns the empty sequence if the request is not a multi-part request or the parameter name does not point to a file part.

Parameters:
$upload-param-name The parameter name
Returns:
xs:double* : the size of the uploaded files

request:get-uri

request:get-uri() as xs:anyURI

Returns the URI of the current request. This will be the original URI as received from the client. Possible modifications done by the URL rewriter will not be visible.

Returns:
xs:anyURI : the URI of the request

request:get-url

request:get-url() as xs:string

Returns the URL of the current request.

Returns:
xs:string : the URL of the current request

request:is-multipart-content

request:is-multipart-content() as xs:boolean

Determine if the request contains multipart/form-data

Returns:
xs:boolean : true is the request is a multipart/form-data request else false.

request:set-attribute

request:set-attribute($name as xs:string, $value as item()*) as item()

Stores a value in the current request using the supplied attribute name.

Parameters:
$name The attribute name
$value* The attribute value
Returns:
item()