A RESTful browser for eXist Java-Based 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:create-session() empty()
Initialize an HTTP session if not already present

Deprecated: Moved to the 'session' module. See session:create. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

request:encode-url($url as xs:anyURI) xs:anyURI
Encodes the specified URL with the current HTTP session-id.
$urlThe URL to encode

Returns the encoded URL

Deprecated: Moved to the 'session' module. See session:encode-url. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

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 its a binary document xs:base64Binary is returned or if its an XML document a node() is returned. All other data is returned as an xs:string representaion. Returns an empty sequence if there is no data.

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 the parameter value

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 the parameter value

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-request-data() item()?
Returns the content of a POST request. If its a binary document xs:base64Binary is returned or if its an XML document a node() is returned. All other data is returned as an xs:string representaion. Returns an empty sequence if there is no data.

Returns the content of a POST request

Deprecated: Renamed to get-data. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

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-session-attribute($name as xs:string) xs:string*
Returns an attribute stored in the current session object or an empty sequence if the attribute cannot be found.
$nameThe session attribute name

Returns the attribute value

Deprecated: Moved to 'session' module. Renamed to session:get-attribute This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

request:get-session-id() xs:string?
Returns the ID of the current session or an empty sequence if there is no session.

Returns the session ID

Deprecated: Moved to session module and renamed to session:get-id. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

request:get-uploaded-file($upload-param-name as xs:string) item()?
Retrieve the Java file object 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

Deprecated: Deprecated in favour of get-uploaded-file-data() This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

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:invalidate-session() empty()
Invalidate (remove) the current HTTP session if present

Deprecated: Moved to 'session' module and renamed to session:invalidate This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

request: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:redirect-to($uri as xs:anyURI) empty()
Sends a HTTP redirect response (302) to the client. Note: this is not supported by the Cocooon generator. Use a sitemap redirect instead.
$uriThe URI to redirect the client to

Deprecated: Moved to 'response' module. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

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

Returns the hostname of the current request

Deprecated: Renamed to request:get-hostname. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

request:request-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 the parameter value

Deprecated: Renamed to request:get-parameter. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

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

Returns the server nodename of the current request

Deprecated: Renamed to request:get-server-name. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

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

Returns the server port of the current request

Deprecated: Renamed to request:get-server-port. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

request:request-uri() xs:anyURI
Returns the URI of the current request.

Returns the URI of the request

Deprecated: Renamed to request:get-uri. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

request:session-attributes() xs:string*
Returns a sequence containing the names of all session attributes defined within the current HTTP session.

Returns the list of attribute names

Deprecated: Moved to session module and renamed to session:get-attribute-names. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

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

request:set-current-user($user-name as xs:string, $password as xs:string) xs:boolean?
Change the user identity for the current HTTP session. Subsequent XQueries in the session will run with the new user identity.
$user-nameThe user name
$passwordThe password

Returns true if the user name and password represent a valid user

Deprecated: Moved to session module. See session:set-current-user. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

request:stream-binary($binary-data as xs:base64Binary, $content-type as xs:string, ...) empty()
Streams the binary data to the current servlet response output stream. The ContentType HTTP header is set to the value given in $content-type.This function only works within a servlet context, not within Cocoon. Note: the servlet output stream will be closed afterwards and mime-type settings in the prolog will not be passed.
$binary-dataThe binary data to stream
$content-typeThe ContentType HTTP header value

Deprecated: Renamed to response:stream-binary. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

request:unescape-uri($escaped-string as xs:string, $encoding as xs:string) xs:string
Returns an un-escaped URL escaped string with the encoding scheme (e.g. "UTF-8"). Decodes encoded sensitive characters from a URL, for example "%2F" becomes "/", i.e. does the oposite to escape-uri()
$escaped-stringThe escaped string to be un-escaped
$encodingThe encoding scheme to use in the un-escaping of the string

Returns the un-escaped string

Deprecated: Moved to the util module. See util:unescape-uri. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.
Return to list of all modules