Package org.apache.mina.http.api
Class DefaultHttpResponse
- java.lang.Object
-
- org.apache.mina.http.api.DefaultHttpResponse
-
- All Implemented Interfaces:
HttpMessage,HttpResponse
public class DefaultHttpResponse extends java.lang.Object implements HttpResponse
The default implementation for the HTTP response element.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,java.lang.String>headersprivate HttpStatusstatusprivate HttpVersionversion
-
Constructor Summary
Constructors Constructor Description DefaultHttpResponse(HttpVersion version, HttpStatus status, java.util.Map<java.lang.String,java.lang.String> headers)Creates a new DefaultHttpResponse instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsHeader(java.lang.String name)Tells if the message contains some headerjava.lang.StringgetContentType()Gets theContent-Typeheader of the message.java.lang.StringgetHeader(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()HttpVersiongetProtocolVersion()The HTTP version of the messageHttpStatusgetStatus()The HTTP status code for the HTTP response (e.g.booleanisKeepAlive()java.lang.StringtoString()
-
-
-
Field Detail
-
version
private final HttpVersion version
-
status
private final HttpStatus status
-
headers
private final java.util.Map<java.lang.String,java.lang.String> headers
-
-
Constructor Detail
-
DefaultHttpResponse
public DefaultHttpResponse(HttpVersion version, HttpStatus status, java.util.Map<java.lang.String,java.lang.String> headers)
Creates a new DefaultHttpResponse instance- Parameters:
version- The HTTP versionstatus- The HTTP statusheaders- The HTTP headers
-
-
Method Detail
-
getProtocolVersion
public HttpVersion getProtocolVersion()
The HTTP version of the message- Specified by:
getProtocolVersionin interfaceHttpMessage- Returns:
- HTTP/1.0 or HTTP/1.1
-
getContentType
public java.lang.String getContentType()
Gets theContent-Typeheader of the message.- Specified by:
getContentTypein interfaceHttpMessage- Returns:
- The content type.
-
isKeepAlive
public boolean isKeepAlive()
- Specified by:
isKeepAlivein interfaceHttpMessage- Returns:
trueif 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:
getHeaderin interfaceHttpMessage- 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:
containsHeaderin interfaceHttpMessage- Parameters:
name- the Header's name we are looking for- Returns:
trueif 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:
getHeadersin interfaceHttpMessage- Returns:
- a read-only
Mapof HTTP headers whose key is aStringand whose value is aStrings.
-
getStatus
public HttpStatus getStatus()
The HTTP status code for the HTTP response (e.g. 200 for OK, 404 for not found, etc..)- Specified by:
getStatusin interfaceHttpResponse- Returns:
- the status of the HTTP response
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-