(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.
abstract Uri? host()
Attempts to determine the original
hostHTTP request header.
Proxy servers such as httpd or AWS ELB, often replace the originating client's
hostheader with their own. This method attempts to untangle common proxy request headers to reform the original
hostcan be useful to ensure clients contact the correct (sub) domain, and web apps may redirect them if not.
hostvalue is formed by inspecting, in order:
forwardedHTTP header as per RFC 7239
X-Forwarded-XXXXde-facto standard headers
Typical responses may be:
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
abstract Str httpMethod()
The HTTP request method in uppercase. Example: GET, POST, PUT.
abstract Version httpVersion()
The HTTP version of the request.
abstract Bool isXmlHttpRequest()
XMLHttpRequest, as specified by the
abstract Locale locales()
The accepted locales for this request based on the "Accept-Language" HTTP header. List is sorted by preference, where
locales.firstis best, and
locales.lastis worst. This list is guaranteed to contain Locale("en").
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()
Stashallows 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()
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
hostshould it have been lost / replaced by a proxy.
host() + WebReq.absUri
abstract Str urlPath()
The url path component, cached.