A RESTful browser for eXist Function Modules


http://exist-db.org/xquery/request
A module for dealing with HTTP requests.

request:attribute-names() xs:string*
Returns the names of all request attributes in the current request.

Returns the names of all attributes attached to the current request

request:exists() xs:boolean
Returns whether a request object exists.

Returns true if the request object exists

request:get-attribute($attribute-name as xs:string) 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.
$attribute-nameThe name of the attribute

Returns the string value of the requested attribute

request:get-context-path() 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 the context path of the current request

request:get-cookie-names() xs:string*
Returns the names of all Cookies in the request

Returns a sequence of the names of all Cookies in the request

request:get-cookie-value($cookie-name as xs:string) xs:string?
Returns the value of a named Cookie.
$cookie-nameThe name of the cookie to retrieve the value from.

Returns the value of the named Cookie

request:get-data() 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 the content of a POST request

request:get-effective-uri() 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 the URI of the request

request:get-header($header-name as xs:string) 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.
$header-nameThe HTTP request header name

Returns the HTTP request header value

request:get-header-names() xs:string*
Returns a sequence containing the names of all headers passed in the current request

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

request:get-hostname() xs:string
Returns the hostname of the current request.

Returns the hostname of the current request

request:get-method() xs:string
Returns the HTTP method of the current request.

Returns the HTTP method of the current request

request:get-parameter($name as xs:string, $default-value as item()*) 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.
$nameThe parameter name
$default-valueThe default value if the parameter does not exist

Returns a sequence of parameter values

request:get-parameter($name as xs:string, $default-value as item()*, $failonerror as xs:boolean*) 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.
$nameThe parameter name
$default-valueThe default value if the parameter does not exist
$failonerrorThe 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 a sequence of parameter values

request:get-parameter-names() xs:string*
Returns a sequence containing the names of all parameters passed in the current request

Returns the sequence containing the names of all parameters

request:get-path-info() 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 the request path information

request:get-query-string() xs:string?
Returns the full query string passed to the servlet (without the initial question mark).

Returns the query string

request:get-remote-addr() xs:string
Returns the IP address of the client machine that made the current request, as a string.

Returns the IP address

request:get-remote-host() xs:string
Returns the fully qualified name of the client or the last proxy that sent the current request.

Returns the host name

request:get-remote-port() xs:integer
Returns the Internet Protocol (IP) source port of the client or last proxy that sent the current request.

Returns the IP port number

request:get-scheme() xs:string
Returns the name of the scheme used in the current request, for example, http, https, or ftp.

Returns the scheme of the current request

request:get-server-name() xs:string
Returns the server nodename of the current request.

Returns the server nodename of the current request

request:get-server-port() xs:integer
Returns the server port of the current request.

Returns the server port of the current request

request:get-servlet-path() 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 the servlet path of the current request

request:get-uploaded-file-data($upload-param-name as xs:string) 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.
$upload-param-nameThe parameter name

Returns the base64 encoded data from the uploaded file

request:get-uploaded-file-name($upload-param-name as xs:string) 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.
$upload-param-nameThe parameter name

Returns the file name of the uploaded file

request:get-uploaded-file-size($upload-param-name as xs:string) 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.
$upload-param-nameThe parameter name

Returns the size of the uploaded file

request:get-uri() 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 the URI of the request

request:get-url() xs:string
Returns the URL of the current request.

Returns the URL of the current request

request:is-multipart-content() xs:boolean
Determine if the request contains multipart/form-data

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

request:set-attribute($name as xs:string, $value as item()*) empty()
Stores a value in the current request using the supplied attribute name.
$nameThe attribute name
$valueThe attribute value
Return to list of all modules