Libraries anvil net Request

class Request
extends anvil.lang.object
The HTTP request from the client terminal/browser.

All request parameters (URL parameters and FORM parameters) appear as request's fields. For example, if the query string contains "a=1&b=2", there will be two fields available in the request: request.a and request.b

If parameter names contains "keys" enclosed into angle brackets corresponding array structures are created onto request. For example:

   <input type="person[name]"  value="john doe">
   <input type="person[age]"  value="50">
   
When submitted will yield to attribute person to request with value ["name"=>"john doe", "age"=>"50"].

Handles also file uploads. For example:

    <form method="post" ENCTYPE="multipart/form-data">
    <input type="file" name="file1">
    </form>
    
Here the request.file1 field will contain a File datatype, which represents an uploaded file.


Methods

string getAuthType()
Returns the name of the authentication scheme. Used to protect the "site servlet", for example, "BASIC" or "SSL," or null if the servlet was not protected.
Returns the name of the authentication scheme

getCharacterEncoding()

string getContentLength()
Returns the length, in bytes, of the request body and made available by the input stream, or -1 if the length is not known.
Returns content length

string getContentType()
Returns the MIME type of the body of the request, or null if the type is not known.
Returns content type

string getContextPath()
Returns the portion of the request URI that indicates the context of the request.
Returns context path

list getCookies()
Returns list containing all cookies that browser sent with this request.

string getHeader(string headerName)
Returns the value of the specified request header as a string. If the request did not include a header of the specified name, this method returns null. The header name is case insensitive. Some useful headers for detecting the client type are "User-Agent" and "Accept".
Parameters headerName -  header name
Returns header

array getHeaderNames()
Returns an array of all the header names this request contains.
Returns header names

string getMethod()
Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.
Returns the HTTP method

string getPathInfo()
Returns any extra path information associated with the URL the client sent when it made this request.
Returns path info

string getProtocol()
Returns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1.
Returns protocol

string getQueryString()
Returns the query string that is contained in the request URL after the path.
Returns query string

string getRemoteAddr()
Returns the Internet Protocol (IP) address of the client that sent the request.
Returns remote address

string getRemoteHost()
Returns the fully qualified name of the client that sent the request, or the IP address of the client if the name cannot be determined.
Returns remote host

string getRemoteUser()
Returns the login of the user making this request, if the user has been authenticated, or null if the user has not been authenticated.
Returns remote user

string getRequestedSessionId()
Returns the session ID specified by the client.

string getRequestURI()
Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request.
Returns request URI

getScheme()

string getServerName()
Returns the host name of the server that received the request.
Returns server name

string getServerPort()
Returns the port number on which this request was received.
Returns server port

string getServletPath()
Returns the part of this request's URL that calls the servlet.
Returns servlet path

Session getSession()
Session getSession(boolean create)
Returns the current session associated with this request. Session returned by this method is independent from Anvil's session handling mechanism as it is provided by enclosing servlet container.
Parameters create -  If true and there is no session, returns a new session

boolean isRequestSessionIdFromCookie()
Checks whether the requested session ID came in as a cookie.

boolean isRequestedSessionIdFromURL()
Checks whether the requested session ID came in as part of the request URL.

boolean isRequestedSessionValid()
Checks whether the requested session ID is still valid.


Attributes

object request.parameter
Parameter from request. For ordinary parameters string is returned, for uploads anvil.io.File is returned and for parameters containing list of angle bracketed keys an array is returned.


References

Parameter from request. For ordinary parameters string is returned, for uploads anvil.io.File is returned and for parameters containing list of angle bracketed keys an array is returned.