Class HttpRequest

java.lang.Object
com.invirgance.convirgance.web.http.HttpRequest

public class HttpRequest extends Object
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 Details

    • HttpRequest

      public HttpRequest(Object request)
      Creates a HttpRequest using the provided object.
      Parameters:
      request - An objects with request options.
  • Method Details

    • getContextPath

      public String getContextPath()
      Gets the context/request path.
      Returns:
      The path.
    • getDateHeader

      public long getDateHeader(String name)
      Gets epoch for the provided date header.
      Parameters:
      name - A date header.
      Returns:
      The date.
    • getHeader

      public String getHeader(String name)
      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

      public Iterable<String> getHeaders(String name)
      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

      public Iterable<String> getHeaderNames(String name)
      Returns the request headers with the name.
      Parameters:
      name - A header name.
      Returns:
      The value as an Iterable.
    • getIntHeader

      public int getIntHeader(String name)
      Returns the request header with the name.
      Parameters:
      name - A header name.
      Returns:
      The value parsed as an int.
    • getLongHeader

      public long getLongHeader(String name)
      Returns the request header with the name.
      Parameters:
      name - A header name.
      Returns:
      The value parsed as an long.
    • getMethod

      public String getMethod()
      Returns the request method.
      Returns:
      The method.
    • getPathInfo

      public String getPathInfo()
      Returns the path info including extra information after the path.
      Returns:
      The request path.
    • getPathTranslated

      public String 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

      public String getQueryString()
      Returns query information included after the request path.
      Returns:
      A string.
    • getRequestURI

      public String getRequestURI()
      Returns the full request path, including the protocol but not the query string.
      Returns:
      The URI.
    • getRequestURL

      public String getRequestURL()
      Returns the request URL.
      Returns:
      The URL.
    • getServletPath

      public String getServletPath()
      Returns the servlet path.
      Returns:
      The path.
    • getCharacterEncoding

      public String getCharacterEncoding()
      Returns the character encoding provided in the request.
      Returns:
      The character encoding.
    • getContentType

      public String getContentType()
      Returns the content-type request header.
      Returns:
      The content type.
    • getInputStream

      public InputStream getInputStream()
      Returns an InputStream of the requests body.
      Returns:
      The body.
    • getParameter

      public String getParameter(String name)
      Returns the value of the parameter.
      Parameters:
      name - Parameter name.
      Returns:
      The value.
    • getParameterNames

      public Iterable<String> getParameterNames()
      Returns the parameters names.
      Returns:
      An Iterable of the parameter names.
    • getParameterValues

      public String[] getParameterValues(String name)
      Returns the values for the parameter with the provided name.
      Parameters:
      name - The parameter name.
      Returns:
      An array containing the values.
    • getParameterMap

      public Map<String,String[]> getParameterMap()
      Returns a map representing the request information.
      Returns:
      The request.
    • getProtocol

      public String getProtocol()
      Returns the protocol used for the request.
      Returns:
      The protocol.
    • getScheme

      public String getScheme()
      Returns the scheme used for the request. Example: HTTP, HTTPS
      Returns:
      The scheme.
    • getServerName

      public String 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

      public String 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

      public String 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

      public Locale getLocale()
      Returns the language local of the request.
      Returns:
      The language.
    • getLocales

      public Iterable<Locale> getLocales()
      Returns the accepted languages of the client.
      Returns:
      The languages.
    • getLocalAddress

      public String getLocalAddress()
      Returns the IP the request was received on.
      Returns:
      The IP.
    • getLocalName

      public String 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.