Class HttpRequestImpl

java.lang.Object
org.apache.mina.http.HttpRequestImpl
All Implemented Interfaces:
HttpMessage, HttpRequest

public class HttpRequestImpl extends Object implements HttpRequest
A HTTP Request implementation
  • Field Details

    • version

      private final HttpVersion version
      The HTTP version
    • method

      private final HttpMethod method
      The HTTP method
    • requestedPath

      private final String requestedPath
      The requested path
    • queryString

      private final String queryString
      The query string
    • headers

      private final Map<String,String> headers
      The set of headers
  • Constructor Details

    • HttpRequestImpl

      public HttpRequestImpl(HttpVersion version, HttpMethod method, String requestedPath, String queryString, Map<String,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 Details

    • getProtocolVersion

      public HttpVersion getProtocolVersion()
      The HTTP version of the message
      Specified by:
      getProtocolVersion in interface HttpMessage
      Returns:
      HTTP/1.0 or HTTP/1.1
    • getContentType

      public 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 String getHeader(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(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 Map<String,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(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 String getParameter(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 Matcher parameterPattern(String name)
    • getParameters

      public Map<String, List<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 String getQueryString()
      Specified by:
      getQueryString in interface HttpRequest
      Returns:
      The query part
    • getMethod

      public HttpMethod getMethod()
      Return the HTTP method used for this message HttpMethod
      Specified by:
      getMethod in interface HttpRequest
      Returns:
      the method
    • getRequestPath

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

      public String toString()
      Overrides:
      toString in class Object