const mixinafBedSheet::HttpRequest
afBedSheet::HttpRequest
(Service) - An injectable const
version of WebReq.
This class will always refer to the current web request.
abstract HttpRequestBody body()
Returns the request body.
abstract HttpRequestHeaders headers()
Map of HTTP request headers. The map is readonly and case insensitive.
@see web::WebReq.headers
@see http://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Requests
abstract Uri? host()
Attempts to determine the original
host
HTTP request header.Proxy servers such as httpd or AWS ELB, often replace the originating client's
Host
header with their own. This method attempts to untangle common proxy request headers to reform the originalHost
.The
Host
can be useful to ensure clients contact the correct (sub) domain, and web apps may redirect them if not.The
Host
value is formed by inspecting, in order:- the
Forwarded
HTTP header as per RFC 7239 - the
X-Forwarded-XXXX
de-facto standard header - the
Host
standard header
Typical responses may be:
http://fantom-lang.org/ //fantom-lang.org/
The scheme may be missing if it can not be reliably obtained.
HTTP 1.0 requests are not required to send a host header, for which this method returns
null
.- the
abstract Str httpMethod()
The HTTP request method in uppercase. Example: GET, POST, PUT.
@see web::WebReq.method
abstract Version httpVersion()
The HTTP version of the request.
@see web::WebReq.version
abstract Bool isXmlHttpRequest()
Returns
true
if anXMLHttpRequest
, as specified by theX-Requested-With
HTTP header.abstract Locale[] locales()
The accepted locales for this request based on the "Accept-Language" HTTP header. List is sorted by preference, where
locales.first
is best, andlocales.last
is worst. This list is guaranteed to contain Locale("en").@see web::WebReq.locales
abstract Void parseMultiPartForm(|Str,InStream,Str:Str callback)
This method will:
- Check that the content-type is form-data
- Get the boundary string
- Invoke the callback for each part
For each part in the stream this calls the given callback function with the part's name, headers, and an input stream used to read the part's body.
abstract IpAddr remoteAddr()
The IP host address of the client socket making this request.
abstract Int remotePort()
The IP port of the client socket making this request.
abstract SocketOptions socketOptions()
Stash
allows you to store temporary data on the request, to easily pass it between services and objects.It is good for a quick win, but if you find yourself consistently relying on it, consider making a thread scoped service instead.
abstract Uri url()
The URL relative to BedSheetWebMod, includes query string and fragment. Always starts with a
/
.Examples:
/a/b/index.html /a?q=bar
This is equivalent to a local URL.
@see web::WebReq.modRel
abstract Uri urlAbs()
Returns the absolute request URL including the full authority, mod path, and the query string. If defined, this is taken from the BedSheetConfigIds.host config value othereise efforts are made to restore the original HTTP header
host
should it have been lost / replaced by a proxy.Equivalent(ish) to:
host() + WebReq.absUri
Examples:
http://www.foo.com/a/b/index.html http://www.foo.com/a?q=bar
@see host @see web::WebReq.absUri
abstract Str[] urlPath()
The url path component, cached.