Class DefaultHttpResponse

java.lang.Object
org.apache.mina.http.api.DefaultHttpResponse
All Implemented Interfaces:
HttpMessage, HttpResponse

public class DefaultHttpResponse extends Object implements HttpResponse
The default implementation for the HTTP response element.
  • Field Details

  • Constructor Details

    • DefaultHttpResponse

      public DefaultHttpResponse(HttpVersion version, HttpStatus status, Map<String,String> headers)
      Creates a new DefaultHttpResponse instance
      Parameters:
      version - The HTTP version
      status - The HTTP status
      headers - The HTTP 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.
    • getStatus

      public HttpStatus getStatus()
      The HTTP status code for the HTTP response (e.g. 200 for OK, 404 for not found, etc..)
      Specified by:
      getStatus in interface HttpResponse
      Returns:
      the status of the HTTP response
    • toString

      public String toString()
      Overrides:
      toString in class Object