Difference between revisions of "Request Module"
Jump to navigation
Jump to search
m (Text replace - "{| width='100%'" to "{|") |
m (Text replace - "{|" to "{| width='100%'") |
||
| Line 25: | Line 25: | ||
==request:method== | ==request:method== | ||
| − | {| | + | {| width='100%' |
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
| Line 37: | Line 37: | ||
==request:scheme== | ==request:scheme== | ||
| − | {| | + | {| width='100%' |
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
| Line 50: | Line 50: | ||
==request:hostname== | ==request:hostname== | ||
| − | {| | + | {| width='100%' |
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
| Line 63: | Line 63: | ||
==request:port== | ==request:port== | ||
| − | {| | + | {| width='100%' |
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
| Line 76: | Line 76: | ||
==request:path== | ==request:path== | ||
| − | {| | + | {| width='100%' |
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
| Line 89: | Line 89: | ||
==request:query== | ==request:query== | ||
| − | {| | + | {| width='100%' |
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
| Line 102: | Line 102: | ||
==request:uri== | ==request:uri== | ||
| − | {| | + | {| width='100%' |
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
| Line 117: | Line 117: | ||
==request:address== | ==request:address== | ||
| − | {| | + | {| width='100%' |
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
| Line 127: | Line 127: | ||
==request:remote-hostname== | ==request:remote-hostname== | ||
| − | {| | + | {| width='100%' |
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
| Line 137: | Line 137: | ||
==request:remote-address== | ==request:remote-address== | ||
| − | {| | + | {| width='100%' |
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
| Line 147: | Line 147: | ||
==request:remote-port== | ==request:remote-port== | ||
| − | {| | + | {| width='100%' |
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
| Line 159: | Line 159: | ||
==request:parameter-names== | ==request:parameter-names== | ||
| − | {| | + | {| width='100%' |
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
| Line 172: | Line 172: | ||
==request:parameter== | ==request:parameter== | ||
| − | {| | + | {| width='100%' |
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
| Line 187: | Line 187: | ||
==request:header-names== | ==request:header-names== | ||
| − | {| | + | {| width='100%' |
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
| Line 197: | Line 197: | ||
==request:header== | ==request:header== | ||
| − | {| | + | {| width='100%' |
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
| Line 209: | Line 209: | ||
==request:cookie-names== | ==request:cookie-names== | ||
| − | {| | + | {| width='100%' |
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
| Line 219: | Line 219: | ||
==request:cookie== | ==request:cookie== | ||
| − | {| | + | {| width='100%' |
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
Revision as of 15:24, 21 December 2012
This XQuery Module contains functions for retrieving information on an HTTP request that has triggered the query. It is mainly useful in the context of Web Applications.
The module is mainly derived from Adam Retter’s upcoming EXQuery Request Module.
Contents
Conventions
All functions in this module are assigned to the http://exquery.org/ns/request namespace, which must be dynamically imported:
import module namespace request = "http://exquery.org/ns/request"; ...
In this documentation, the namespace is bound to the request prefix.
The following example will be referenced in the function definitions. It demonstrates what components a URI may consist of (the example is derived from RFC 3986):
foo://example.com:8042/over/there?name=ferret \_/ \_________/ \__/\_________/ \_________/ | | | | | scheme hostname port path query
General Functions
request:method
| Signatures | request:method() as xs:string
|
| Summary | Returns the Method of the HTTP request. |
URI Functions
request:scheme
| Signatures | request:scheme() as xs:string
|
| Summary | Returns the Scheme component of the URI of an HTTP request. |
| Example | For the example given in the introduction, this function would return foo.
|
request:hostname
| Signatures | request:hostname() as xs:string
|
| Summary | Returns the Hostname component of the URI of an HTTP request. |
| Example | For the example given in the introduction, this function would return example.com.
|
request:port
| Signatures | request:port() as xs:integer
|
| Summary | Returns the Port component of the URI of an HTTP request, or a default port if it has not been explicitly specified in the URI. |
| Example | For the example given in the introduction, this function would return 8042.
|
request:path
| Signatures | request:path() as xs:string
|
| Summary | Returns the Path component of the URI of an HTTP request. |
| Example | For the example given in the introduction, this function would return /over/there. |
request:query
| Signatures | request:query() as xs:string?
|
| Summary | Returns the Query component of the URI of an HTTP request. If no query has been specified, an empty sequence is returned. |
| Example | For the example given in the introduction, this function would return {{{1}}}. |
request:uri
| Signatures | request:uri() as xs:anyURI
|
| Summary | Returns the complete URI of an HTTP request as it has been specified by the client. |
| Example | For the example given in the introduction, this method would return {{{1}}}. |
Connection Functions
request:address
| Signatures | request:address() as xs:string
|
| Summary | Returns the IP address of the server. |
request:remote-hostname
| Signatures | request:remote-hostname() as xs:string
|
| Summary | Returns the fully qualified hostname of the client that sent the request. |
request:remote-address
| Signatures | request:remote-address() as xs:string
|
| Summary | Returns the IP address of the client that sent the request. |
request:remote-port
| Signatures | request:remote-port() as xs:string
|
| Summary | Returns the TCP port of the client socket that triggered the request. |
Parameter Functions
request:parameter-names
| Signatures | request:parameter-names() as xs:string*
|
| Summary | Returns the names of all query parameters available from the HTTP request. If RESTXQ is used, this function may help to find query parameters that have not been bound by %restxq:query-param annotations. |
| Example | For the example given in the introduction, this function would return name. |
request:parameter
| Signatures | request:parameter($name as xs:string) as xs:string*request:parameter($name as xs:string, $default as xs:string) as xs:string*
|
| Summary | Returns the value of the named query parameter in an HTTP request. If the parameter does not exist, an empty sequence or the optionally specified default value is returned instead. |
| Example | For the example given in the introduction, the function call request:parameter('name') would return ferret. |
Header Functions
request:header-names
| Signatures | request:header-names() as xs:string*
|
| Summary | Returns the names of all headers available from the HTTP request. If RESTXQ is used, this function may help to find headers that have not been bound by %restxq:header-param annotations. |
request:header
| Signatures | request:header($name as xs:string) as xs:string?header:parameter($name as xs:string, $default as xs:string) as xs:string
|
| Summary | Returns the value of the named header in an HTTP request. If the header does not exist, an empty sequence or the optionally specified default value is returned instead. |
Cookie Functions
request:cookie-names
| Signatures | request:cookie-names() as xs:string*
|
| Summary | Returns the names of all cookies in the HTTP headers available from the HTTP request. If RESTXQ is used, this function may help to find cookies that have not been bound by %restxq:cookie-param annotations. |
request:cookie
| Signatures | request:cookie($name as xs:string) as xs:string*header:cookie($name as xs:string, $default as xs:string) as xs:string
|
| Summary | Returns the value of the named Cookie in an HTTP request. If there is no such cookie, an empty sequence or the optionally specified default value is returned instead. |
Changelog
This module was introduced with Version 7.5.