Class HttpRequest
java.lang.Object
com.invirgance.convirgance.web.http.HttpRequest
Wrapper for HTTP servlet request objects.
Provides access to common HTTP request elements: - Request parameters and headers - Request path information - Client and server information - Request body content
- Author:
- jbanes
-
Constructor Summary
ConstructorsConstructorDescriptionHttpRequest
(Object request) Creates a HttpRequest using the provided object. -
Method Summary
Modifier and TypeMethodDescriptionReturns the character encoding provided in the request.Returns the content-type request header.Gets the context/request path.long
getDateHeader
(String name) Gets epoch for the provided date header.Returns the value of the provided header.getHeaderNames
(String name) Returns the request headers with the name.getHeaders
(String name) Returns the value of the provided header.Returns anInputStream
of the requests body.int
getIntHeader
(String name) Returns the request header with the name.Returns the IP the request was received on.Returns the language local of the request.Returns the accepted languages of the client.Returns the host name the request was received on.int
Returns the port the request was received on.long
getLongHeader
(String name) Returns the request header with the name.Returns the request method.getParameter
(String name) Returns the value of the parameter.Returns a map representing the request information.Returns the parameters names.String[]
getParameterValues
(String name) Returns the values for the parameter with the provided name.Returns the path info including extra information after the path.Returns any extra path information after the servlet name but before the query string, and translated it into a real pathReturns the protocol used for the request.Returns query information included after the request path.Returns the IP address of the client.Returns the fully qualified host name the request was made from.int
Returns the port the clients request was made from.Returns the full request path, including the protocol but not the query string.Returns the request URL.Returns the scheme used for the request.Returns the host name of the request.int
Returns the port the request was sent from.Returns the servlet path.
-
Constructor Details
-
HttpRequest
Creates a HttpRequest using the provided object.- Parameters:
request
- An objects with request options.
-
-
Method Details
-
getContextPath
Gets the context/request path.- Returns:
- The path.
-
getDateHeader
Gets epoch for the provided date header.- Parameters:
name
- A date header.- Returns:
- The date.
-
getHeader
Returns the value of the provided header. For example "Accept-Encoding" would return the supported types of compression encoding.- Parameters:
name
- A header name.- Returns:
- The value.
-
getHeaders
Returns the value of the provided header. For example "Accept-Encoding" would return the supported types of compression encoding.- Parameters:
name
- A header name.- Returns:
- The value as an
Iterable
.
-
getHeaderNames
Returns the request headers with the name.- Parameters:
name
- A header name.- Returns:
- The value as an
Iterable
.
-
getIntHeader
Returns the request header with the name.- Parameters:
name
- A header name.- Returns:
- The value parsed as an int.
-
getLongHeader
Returns the request header with the name.- Parameters:
name
- A header name.- Returns:
- The value parsed as an long.
-
getMethod
Returns the request method.- Returns:
- The method.
-
getPathInfo
Returns the path info including extra information after the path.- Returns:
- The request path.
-
getPathTranslated
Returns any extra path information after the servlet name but before the query string, and translated it into a real path- Returns:
- The path.
-
getQueryString
Returns query information included after the request path.- Returns:
- A string.
-
getRequestURI
Returns the full request path, including the protocol but not the query string.- Returns:
- The URI.
-
getRequestURL
Returns the request URL.- Returns:
- The URL.
-
getServletPath
Returns the servlet path.- Returns:
- The path.
-
getCharacterEncoding
Returns the character encoding provided in the request.- Returns:
- The character encoding.
-
getContentType
Returns the content-type request header.- Returns:
- The content type.
-
getInputStream
Returns anInputStream
of the requests body.- Returns:
- The body.
-
getParameter
Returns the value of the parameter.- Parameters:
name
- Parameter name.- Returns:
- The value.
-
getParameterNames
Returns the parameters names.- Returns:
- An
Iterable
of the parameter names.
-
getParameterValues
Returns the values for the parameter with the provided name.- Parameters:
name
- The parameter name.- Returns:
- An array containing the values.
-
getParameterMap
Returns a map representing the request information.- Returns:
- The request.
-
getProtocol
Returns the protocol used for the request.- Returns:
- The protocol.
-
getScheme
Returns the scheme used for the request. Example: HTTP, HTTPS- Returns:
- The scheme.
-
getServerName
Returns the host name of the request. Could also be the "server name" or the IP address.- Returns:
- The value.
-
getServerPort
public int getServerPort()Returns the port the request was sent from.- Returns:
- The port number.
-
getRemoteAddress
Returns the IP address of the client. If the client is behind a proxy ex Cloudflare, that IP would be returned instead.- Returns:
- The IP address.
-
getRemoteHost
Returns the fully qualified host name the request was made from.- Returns:
- The FQ name.
-
getRemotePort
public int getRemotePort()Returns the port the clients request was made from.- Returns:
- The port.
-
getLocale
Returns the language local of the request.- Returns:
- The language.
-
getLocales
Returns the accepted languages of the client.- Returns:
- The languages.
-
getLocalAddress
Returns the IP the request was received on.- Returns:
- The IP.
-
getLocalName
Returns the host name the request was received on.- Returns:
- The host name.
-
getLocalPort
public int getLocalPort()Returns the port the request was received on.- Returns:
- Port number.
-