Class HttpContext

  • All Implemented Interfaces:
    Context

    public final class HttpContext
    extends AbstractContext
    A Context containing information relating to the originating HTTP request.
    • Constructor Detail

      • HttpContext

        public HttpContext​(JsonValue savedContext,
                           ClassLoader classLoader)
        Restore from JSON representation.
        Parameters:
        savedContext - The JSON representation from which this context's attributes should be parsed. Must be a JSON Object that contains ATTR_HEADERS and ATTR_PARAMETERS attributes.
        classLoader - The ClassLoader which can properly resolve the persisted class-name.
    • Method Detail

      • getHeader

        public List<String> getHeader​(String name)
        Returns an unmodifiable list containing the values of the named HTTP request header.
        Parameters:
        name - The name of the HTTP request header.
        Returns:
        An unmodifiable list containing the values of the named HTTP request header, which may be empty if the header is not present in the request.
      • getHeaderAsString

        public String getHeaderAsString​(String name)
        Returns the first value of the named HTTP request header.
        Parameters:
        name - The name of the HTTP request header.
        Returns:
        The first value of the named HTTP request header, or null if the header is not present in the request.
      • getHeaders

        public Map<String,​List<String>> getHeaders()
        Returns an unmodifiable map of the HTTP request headers.
        Returns:
        An unmodifiable map of the HTTP request headers.
      • getMethod

        public String getMethod()
        Returns the effective HTTP method, taking into account presence of the X-HTTP-Method-Override header.
        Returns:
        The effective HTTP method, taking into account presence of the X-HTTP-Method-Override header.
      • getParameter

        public List<String> getParameter​(String name)
        Returns an unmodifiable list containing the values of the named HTTP request parameter.
        Parameters:
        name - The name of the HTTP request parameter.
        Returns:
        An unmodifiable list containing the values of the named HTTP request parameter, which may be empty if the parameter is not present in the request.
      • getParameterAsString

        public String getParameterAsString​(String name)
        Returns the first value of the named HTTP request parameter.
        Parameters:
        name - The name of the HTTP request parameter.
        Returns:
        The first value of the named HTTP request parameter, or null if the parameter is not present in the request.
      • getParameters

        public Map<String,​List<String>> getParameters()
        Returns an unmodifiable map of the HTTP request parameters.
        Returns:
        An unmodifiable map of the HTTP request parameters.
      • getPath

        public String getPath()
        Returns the HTTP request path.
        Returns:
        The HTTP request path.