Class Request

java.lang.Object
io.mangoo.routing.bindings.Validator
io.mangoo.routing.bindings.Request
All Implemented Interfaces:
Serializable

public class Request extends Validator
Author:
svenkubiak
See Also:
  • Constructor Details

    • Request

      public Request()
    • Request

      public Request(io.undertow.server.HttpServerExchange httpServerExchange)
  • Method Details

    • withSession

      public Request withSession(Session session)
    • withAuthentication

      public Request withAuthentication(Authentication authentication)
    • withParameter

      public Request withParameter(Map<String,String> parameter)
    • withBody

      public Request withBody(String body)
    • getSession

      public Session getSession()
      Returns:
      The current session
    • getBody

      public String getBody()
      Returns:
      The request body
    • getBodyAsJsonMap

      public Map<String,Object> getBodyAsJsonMap()
      Returns:
      The request body as Map object
    • getBodyAsJsonPath

      public com.jayway.jsonpath.ReadContext getBodyAsJsonPath()
      Returns:
      The request body as JsonPath object
    • getAuthentication

      public Authentication getAuthentication()
      Returns:
      The current authentication
    • getParameter

      public String getParameter(String key)
      Retrieves a request parameter (request or query parameter) by its name
      Parameters:
      key - The key to find the parameter
      Returns:
      The value for the given or null if none found
    • getParameter

      public Map<String,String> getParameter()
      Retrieves a map of request parameter (request or query parameter)
      Returns:
      Map of request and query parameter
    • getHeaders

      public io.undertow.util.HeaderMap getHeaders()
      Retrieves a list of all headers send by the client
      Returns:
      A HeaderMap of client sent headers
    • getAcceptLanguage

      public String getAcceptLanguage()
      Retrieves the clients accepted languages
      Returns:
      the string value of the clients accepted languages
    • getHeader

      public String getHeader(io.undertow.util.HttpString headerName)
      Retrieves a specific header value by its name
      Parameters:
      headerName - The name of the header to retrieve
      Returns:
      The value of the header or null if none found
    • getHeader

      public String getHeader(String headerName)
      Retrieves a specific header value by its name
      Parameters:
      headerName - The name of the header to retrieve
      Returns:
      The value of the header or null if none found
    • getURI

      public String getURI()
      The original request URI. This will include the host name, protocol etc. if it was specified by the client. This is not decoded in any way, and does not include the query string. Examples: GET http://localhost:8080/myFile.jsf?foo=bar HTTP/1.1 -> 'http://localhost:8080/myFile.jsf' POST /my+File.jsf?foo=bar HTTP/1.1 -> '/my+File.jsf'
      Returns:
      The request URI
    • getURL

      public String getURL()
      Reconstructs the complete URL as seen by the user. This includes scheme, host name etc. but does not include query string. This is not decoded.
      Returns:
      The request URL
    • getCookies

      public Map<String,io.undertow.server.handlers.Cookie> getCookies()
      Returns:
      An immutable map of request cookies
    • getCookie

      public io.undertow.server.handlers.Cookie getCookie(String name)
      Retrieves a single cookie from the request
      Parameters:
      name - The name of the cookie
      Returns:
      The Cookie
    • getScheme

      public String getScheme()
      Get the request URI scheme. Normally this is one of http or https.
      Returns:
      the request URI scheme
    • getCharset

      public String getCharset()
      Returns the request charset. If none was explicitly specified it will return "ISO-8859-1", which is the default charset for HTTP requests.
      Returns:
      The character encoding
    • addAttribute

      public void addAttribute(String key, Object value)
      Adds an attribute to the internal attributes map
      Parameters:
      key - The key to store the attribute
      value - The value to store
    • getContentLength

      public long getContentLength()
      Returns:
      The content length of the request, or -1 if it has not been set
    • getMethod

      public io.undertow.util.HttpString getMethod()
      Get the HTTP request method. Normally this is one of the strings listed in Methods.
      Returns:
      the HTTP request method
    • getPath

      public String getPath()
      The request path. This will be decoded by the server, and does not include the query string. This path is not canonical, so care must be taken to ensure that escape attacks are not possible. Examples: GET http://localhost:8080/b/../my+File.jsf?foo=bar HTTP/1.1 -> '/b/../my+File.jsf' POST /my+File.jsf?foo=bar HTTP/1.1 -> '/my File.jsf'
      Returns:
      The request path
    • getAttribute

      public Object getAttribute(String key)
      Returns an object attribute from a given key
      Parameters:
      key - The key the attribute is stored
      Returns:
      Object the value from the attributes map
    • getAttributeAsString

      public String getAttributeAsString(String key)
      Returns an object attribute from a given key
      Parameters:
      key - The key the attribute is stored
      Returns:
      String the value from the attributes map
    • getAttributes

      public Map<String,Object> getAttributes()
      Returns:
      All attributes of the request