Class HttpRequestImpl

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Map<java.lang.String,​java.lang.String> headers
      The set of headers
      private HttpMethod method
      The HTTP method
      private java.lang.String queryString
      The query string
      private java.lang.String requestedPath
      The requested path
      private HttpVersion version
      The HTTP version
    • Constructor Summary

      Constructors 
      Constructor Description
      HttpRequestImpl​(HttpVersion version, HttpMethod method, java.lang.String requestedPath, java.lang.String queryString, java.util.Map<java.lang.String,​java.lang.String> headers)
      Creates a new HttpRequestImpl instance
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean containsHeader​(java.lang.String name)
      Tells if the message contains some header
      boolean containsParameter​(java.lang.String name)
      Determines whether this request contains at least one parameter with the specified name
      java.lang.String getContentType()
      Gets the Content-Type header of the message.
      java.lang.String getHeader​(java.lang.String name)
      Returns the value of the HTTP header with the specified name.
      java.util.Map<java.lang.String,​java.lang.String> getHeaders()
      HttpMethod getMethod()
      Return the HTTP method used for this message HttpMethod
      java.lang.String getParameter​(java.lang.String name)
      Returns the value of a request parameter as a String, or null if the parameter does not exist.
      java.util.Map<java.lang.String,​java.util.List<java.lang.String>> getParameters()
      HttpVersion getProtocolVersion()
      The HTTP version of the message
      java.lang.String getQueryString()
      java.lang.String getRequestPath()
      Return the HTTP request path
      boolean isKeepAlive()
      protected java.util.regex.Matcher parameterPattern​(java.lang.String name)  
      java.lang.String toString()
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • version

        private final HttpVersion version
        The HTTP version
      • method

        private final HttpMethod method
        The HTTP method
      • requestedPath

        private final java.lang.String requestedPath
        The requested path
      • queryString

        private final java.lang.String queryString
        The query string
      • headers

        private final java.util.Map<java.lang.String,​java.lang.String> headers
        The set of headers
    • Constructor Detail

      • HttpRequestImpl

        public HttpRequestImpl​(HttpVersion version,
                               HttpMethod method,
                               java.lang.String requestedPath,
                               java.lang.String queryString,
                               java.util.Map<java.lang.String,​java.lang.String> headers)
        Creates a new HttpRequestImpl instance
        Parameters:
        version - The HTTP version
        method - The HTTP method
        requestedPath - The request path
        queryString - The query string
        headers - The headers
    • Method Detail

      • getContentType

        public java.lang.String getContentType()
        Gets the Content-Type header of the message.
        Specified by:
        getContentType in interface HttpMessage
        Returns:
        The content type.
      • isKeepAlive

        public boolean isKeepAlive()
        Specified by:
        isKeepAlive in interface HttpMessage
        Returns:
        true if this message enables keep-alive connection.
      • getHeader

        public java.lang.String getHeader​(java.lang.String name)
        Returns the value of the HTTP header with the specified name. If more than one header with the given name is associated with this request, one is selected and returned.
        Specified by:
        getHeader in interface HttpMessage
        Parameters:
        name - The name of the desired header
        Returns:
        The header value - or null if no header is found with the specified name
      • containsHeader

        public boolean containsHeader​(java.lang.String name)
        Tells if the message contains some header
        Specified by:
        containsHeader in interface HttpMessage
        Parameters:
        name - the Header's name we are looking for
        Returns:
        true if the HTTP header with the specified name exists in this request.
      • getHeaders

        public java.util.Map<java.lang.String,​java.lang.String> getHeaders()
        Specified by:
        getHeaders in interface HttpMessage
        Returns:
        a read-only Map of HTTP headers whose key is a String and whose value is a String s.
      • containsParameter

        public boolean containsParameter​(java.lang.String name)
        Determines whether this request contains at least one parameter with the specified name
        Specified by:
        containsParameter in interface HttpRequest
        Parameters:
        name - The parameter name
        Returns:
        true if this request contains at least one parameter with the specified name
      • getParameter

        public java.lang.String getParameter​(java.lang.String name)
        Returns the value of a request parameter as a String, or null if the parameter does not exist. If the request contained multiple parameters with the same name, this method returns the first parameter encountered in the request with the specified name
        Specified by:
        getParameter in interface HttpRequest
        Parameters:
        name - The parameter name
        Returns:
        The value
      • parameterPattern

        protected java.util.regex.Matcher parameterPattern​(java.lang.String name)
      • getParameters

        public java.util.Map<java.lang.String,​java.util.List<java.lang.String>> getParameters()
        Specified by:
        getParameters in interface HttpRequest
        Returns:
        a read only Map of query parameters whose key is a String and whose value is a List of Strings.
      • getQueryString

        public java.lang.String getQueryString()
        Specified by:
        getQueryString in interface HttpRequest
        Returns:
        The query part
      • getRequestPath

        public java.lang.String getRequestPath()
        Return the HTTP request path
        Specified by:
        getRequestPath in interface HttpRequest
        Returns:
        the request path
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object