const mixinafBedSheet::HttpRequest

afBedSheet::HttpRequest

(Service) - An injectable const version of WebReq.

This class will always refer to the current web request.

body

Source

abstract HttpRequestBody body()

Returns the request body.

headers

Source

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

host

Source

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 original host.

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:

  1. the forwarded HTTP header as per RFC 7239
  2. the X-Forwarded-XXXX de-facto standard headers
  3. the host standard headers

Typical responses may be:

http://fantom-lang.org/
//fantom-lang.org/

Note how the scheme may be missing if it can not be reliably obtained.

Note HTTP 1.0 requests are not required to send a host header, for which this method returns null.

httpMethod

Source

abstract Str httpMethod()

The HTTP request method in uppercase. Example: GET, POST, PUT.

@see web::WebReq.method

httpVersion

Source

abstract Version httpVersion()

The HTTP version of the request.

@see web::WebReq.version

isXmlHttpRequest

Source

abstract Bool isXmlHttpRequest()

Returns true if an XMLHttpRequest, as specified by the X-Requested-With HTTP header.

locales

Source

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, and locales.last is worst. This list is guaranteed to contain Locale("en").

@see web::WebReq.locales

parseMultiPartForm

Source

abstract Void parseMultiPartForm(|Str,InStream,Str:Str callback)

This method will:

  1. Check that the content-type is form-data
  2. Get the boundary string
  3. 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.

@see web::WebReq.parseMultiPartForm

remoteAddr

Source

abstract IpAddr remoteAddr()

The IP host address of the client socket making this request.

@see web::WebReq.remoteAddr

remotePort

Source

abstract Int remotePort()

The IP port of the client socket making this request.

@see web::WebReq.remotePort

socketOptions

Source

abstract SocketOptions socketOptions()

stash

Source

abstract Str:Obj? stash()

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.

url

Source

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

urlAbs

Source

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