type

WebReq

src abstract class WebReq : Obj

WebReq encapsulates a web request.

See pod doc.

fields

mod

Get the WebMod which is currently responsible for processing this request.

modBase

Base URI of the current WebMod.

methods

absUri

The absolute request URI including the full authority and the query string.

cookies

Map of cookie values keyed by cookie name.

form

Get the key/value pairs of the form data.

headers

Map of HTTP request headers.

in

Get the stream to read request body.

isGet

Return if the method is GET

isPost

Return if the method is POST

locales

Get the accepted locales for this request based on the "Accept-Language" HTTP header.

method

The HTTP request method in uppercase.

modRel

WebMod relative part of the URI - see modBase.

parseMultiPartForm

Given a web request

remoteAddr

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

remotePort

Get the IP port of the client socket making this request.

session

Get the session associated with this browser "connection".

socketOptions

Access to socket options for this request.

stash

Stash allows you to stash objects on the WebReq object in order to pass data b/w Weblets while processing this request.

uri

The request URI including the query string relative to this authority.

version

The HTTP version of the request.

Slot Details

absUri

src virtual Uri absUri()

The absolute request URI including the full authority and the query string. Also see uri, modBase, and modRel. This method is equivalent to:

"http://" + headers["Host"] + uri

Examples:

http://www.foo.com/a/b/c
http://www.foo.com/a?q=bar

cookies

src virtual Str:Str cookies()

Map of cookie values keyed by cookie name. The cookies map is readonly and case insensitive.

form

src virtual [Str:Str]? form()

Get the key/value pairs of the form data. If the request content type is "application/x-www-form-urlencoded", then the first time this method is called the request content is read and parsed using Uri.decodeQuery. If the content type is not "application/x-www-form-urlencoded" this method returns null.

headers

src abstract Str:Str headers()

Map of HTTP request headers. The headers map is readonly and case insensitive (see Map.caseInsensitive).

Examples:

req.headers["Accept-Language"]

in

src abstract InStream in()

Get the stream to read request body. See WebUtil.makeContentInStream to check under which conditions request content is available. If request content is not available, then throw an exception.

If the client specified the "Expect: 100-continue" header, then the first access of the request input stream will automatically send the client a 100 Continue response.

isGet

src abstract Bool isGet()

Return if the method is GET

isPost

src abstract Bool isPost()

Return if the method is POST

locales

src virtual Locale[] locales()

Get 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 guarenteed to contain Locale("en").

method

src abstract Str method()

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

mod

src abstract WebMod mod

Get the WebMod which is currently responsible for processing this request.

modBase

src Uri modBase := `/`

Base URI of the current WebMod. This Uri always ends in a slash. This is the URI used to route to the WebMod itself. The remainder of uri is stored in modRel so that the following always holds true (with exception of a trailing slash):

modBase + modRel == uri

For example if the current WebMod is mounted as /mod then:

uri          modBase   modRel
----------   -------   -------
`/mod`       `/mod/`   ``
`/mod/`      `/mod/`   ``
`/mod?q`     `/mod/`   `?q`
`/mod/a`     `/mod/`   `a`
`/mod/a/b`   `/mod/`   `a/b`

modRel

src Uri modRel()

WebMod relative part of the URI - see modBase.

parseMultiPartForm

src Void parseMultiPartForm(|Str,InStream,Str:Str| cb)

Given a web request:

  1. check that the content-type is form-data
  2. get the boundary string
  3. invoke callback for each part (see WebUtil.parseMultiPart)

For each part in the stream call the given callback function with the part's form name, headers, and an input stream used to read the part's body.

remoteAddr

src abstract IpAddr remoteAddr()

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

remotePort

src abstract Int remotePort()

Get the IP port of the client socket making this request.

session

src abstract WebSession session()

Get the session associated with this browser "connection". The session must be accessed the first time before the response is committed.

socketOptions

src abstract SocketOptions socketOptions()

Access to socket options for this request.

stash

src virtual Str:Obj? stash()

Stash allows you to stash objects on the WebReq object in order to pass data b/w Weblets while processing this request.

uri

src abstract Uri uri()

The request URI including the query string relative to this authority. Also see absUri, modBase, and modRel.

Examples:

/a/b/c
/a?q=bar

version

src abstract Version version()

The HTTP version of the request.