=Conventions=
All functions in this module are assigned to the {{Code|http://exquery.org/ns/restxq/request}} namespace, which must be dynamically imported. In this documentation, the namespace is bound to the {{Code|request}} prefix.
==URI Syntax== =General Functions= ==request:method=={||-| width='90' | '''Signatures'''|{{Func|request:method||xs:string}}|-| '''Summary'''|Returns the method of the HTTP request.|} =URI Functions= The following example show what components a URI consists of (the examples is derived from [http://tools.ietf.org/html/rfc3986 RFC 3986]):<pre> foo://username:password@example.com:8042/over/there/index.dtb?type=animal \_/ \_______________/ \_________/ \__/\___________________/ \_________/ | | | | | |scheme userinfo hostname port path query</pre> ==request:scheme=={||-| width='90' | '''Signatures'''|{{Func|request:scheme||xs:string}}|-| '''Summary'''|Returns the Scheme component of the URI of an HTTP request.|} ==request:hostname=={||-| width='90' | '''Signatures'''|{{Func|request:hostname||xs:string}}|-| '''Summary'''|Returns the Hostname component of the URI of an HTTP request.|} ==request:port=={||-| width='90' | '''Signatures'''|{{Func|request:port||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.|} ==request:path=={||-| width='90' | '''Signatures'''|{{Func|request:port||xs:string}}|-| '''Summary'''|Returns the Path component of the URI of an HTTP request.|} ==request:query=={||-| width='90' | '''Signatures'''|{{Func|request:query||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.|} ==request:uri=={||-| width='90' | '''Signatures'''|{{Func|request:uri||xs:anyURI}}|-| '''Summary'''|Returns the complete URI of an HTTP request as it has been specified by the client.|} =Connection Functions= ==request:address=={||-| width='90' | '''Signatures'''|{{Func|request:address||xs:string}}|-| '''Summary'''|Returns the IP address of the server.|} ==request:remote-hostname=={||-| width='90' | '''Signatures'''|{{Func|request:remote-hostname||xs:string}}|-| '''Summary'''|Returns the fully qualified hostname of the client that sent the request.|} ==request:remote-address=={||-| width='90' | '''Signatures'''|{{Func|request:remote-address||xs:string}}|-| '''Summary'''|Returns the IP address of the client that sent the request.|} ==request:remote-port=={||-| width='90' | '''Signatures'''|{{Func|request:remote-port||xs:string}}|-| '''Summary'''|Returns the TCP port of the client socket that triggered the request.|} =HTTP Parameter Functions=
==request:parameter-names==
{|
|-
|-
| '''Summary'''
|Returns the names of all query parameters contained in available from the HTTP request. This function can be used to find or check query parameters that have not been bound by [[RESTXQ#Query Strings|%restxq:query-param]] annotations.
|}
==request:parameter==
{|
|-
| width='90' | '''Signatures'''
|{{Func|request:parameter|$name as xs:string|xs:string*}}<br/>{{Func|request:parameter|$name as xs:string, $default as xs:string|xs:string*}}
|-
| '''Summary'''
|Returns all strings bound to the value of the named query parameter in an HTTP request. If the parameter does not exist, an empty sequence or the optionally specified by {{Code|$name}}default value is returned instead.
|-
| '''Examples'''
|The following RESTXQ function can e.g. be called via <code><nowiki>http://localhost:8984/restxq/get?keyuser=userJohn</nowiki></code>:
<pre class="brush:xquery">
module namespace test = 'http://basex.org/examples/test';
import module namespace request = "http://exquery.org/ns/restxq/request";
declare %restxq:path("/get") function test:get(){ 'Value of parameter "key": The user name is ' || request:parameter('keyuser')
};
</pre>
|}
=HTTP Header Functions=
==request:header-names==
{|
|-
| width='90' | '''Signatures'''
|{{Func|request:header-names||xs:string*}}
|-
| '''Summary'''
|Returns the names of all headers available from the HTTP request.
|}
==request:header==
{|
|-
| width='90' | '''Signatures'''
|{{Func|request:header|$name as xs:string|xs:string?}}<br/>{{Func|header:parameter|$name as xs:string, $default as xs:string|xs:string}}
|-
| '''Summary'''
|Returns the value of the named HTTP header in an HTTP request. If the header does not exist, an empty sequence or the optionally specified default value is returned instead.
|-
| '''Examples'''
|The following example will return the Hostname and the port of the calling client:
<pre class="brush:xquery">
request:parameter('Host')
</pre>
|}
=HTTP Cookie Functions=
==request:cookie-names==
{|
|-
| width='90' | '''Signatures'''
|{{Func|request:cookie-names||xs:string*}}
|-
| '''Summary'''
|Returns the names of all cookies in the HTTP headers available from the HTTP request.
|}
==request:cookie==
{|
|-
| width='90' | '''Signatures'''
|{{Func|request:cookie|$name as xs:string|xs:string*}}<br/>{{Func|header:cookie|$name as xs:string, $default as xs:string|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.
|-
| '''Examples'''
|The following example will return the Hostname and the port of the calling client:
<pre class="brush:xquery">
request:parameter('Host')
</pre>
|}