Package kilim.http
Class HttpResponse
- java.lang.Object
-
- kilim.http.HttpMsg
-
- kilim.http.HttpResponse
-
public class HttpResponse extends HttpMsg
The response object encapsulates the header and often, but not always, the content. The caller must set all the fields, except for the protocol, server and date. The body of the response (the content) is written to a stream obtained fromgetOutputStream().
-
-
Field Summary
Fields Modifier and Type Field Description ExposedBaosbodyStreamstatic java.util.concurrent.ConcurrentHashMap<java.lang.String,byte[]>byteCachestatic byte[]CRLFstatic byte[]F_DATEstatic byte[]F_SERVERstatic byte[]FIELD_SEPstatic java.text.SimpleDateFormatgmtdfjava.util.ArrayList<java.lang.String>keysstatic byte[]PROTOCOLstatic byte[]ST_ACCEPTEDstatic byte[]ST_BAD_GATEWAYstatic byte[]ST_BAD_REQUESTstatic byte[]ST_CONFLICTstatic byte[]ST_CONTINUEstatic byte[]ST_CREATEDstatic byte[]ST_EXPECTATION_FAILEDstatic byte[]ST_FORBIDDENstatic byte[]ST_FOUNDstatic byte[]ST_GATEWAY_TIMEOUTstatic byte[]ST_GONEstatic byte[]ST_HTTP_VERSION_NOT_SUPPORTEDstatic byte[]ST_INTERNAL_SERVER_ERRORstatic byte[]ST_LENGTH_REQUIREDstatic byte[]ST_METHOD_NOT_ALLOWEDstatic byte[]ST_MOVED_PERMANENTLYstatic byte[]ST_MULTIPLE_CHOICESstatic byte[]ST_NO_CONTENTstatic byte[]ST_NON_AUTHORITATIVEstatic byte[]ST_NOT_ACCEPTABLEstatic byte[]ST_NOT_FOUNDstatic byte[]ST_NOT_IMPLEMENTEDstatic byte[]ST_NOT_MODIFIEDstatic byte[]ST_OKstatic byte[]ST_PARTIAL_CONTENTstatic byte[]ST_PAYMENT_REQUIREDstatic byte[]ST_PRECONDITION_FAILEDstatic byte[]ST_PROXY_AUTHENTICATION_REQUIREDstatic byte[]ST_REQUEST_ENTITY_TOO_LARGEstatic byte[]ST_REQUEST_RANGE_NOT_SATISFIABLEstatic byte[]ST_REQUEST_TIMEOUTstatic byte[]ST_REQUEST_URI_TOO_LONGstatic byte[]ST_RESET_CONTENTstatic byte[]ST_SEE_OTHERstatic byte[]ST_SERVICE_UNAVAILABLEstatic byte[]ST_SWITCHING_PROTOCOLSstatic byte[]ST_TEAPOTstatic byte[]ST_TEMPORARY_REDIRECTstatic byte[]ST_UNAUTHORIZEDstatic byte[]ST_UNSUPPORTED_MEDIA_TYPEstatic byte[]ST_USE_PROXYbyte[]statusThe status line for the response.java.util.ArrayList<java.lang.String>values
-
Constructor Summary
Constructors Constructor Description HttpResponse()HttpResponse(byte[] statusb)HttpResponse(java.lang.String statusMsg)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HttpResponseaddField(java.lang.String key, java.lang.String value)java.lang.StringgetHeaderValue(java.lang.String key)java.io.OutputStreamgetOutputStream()voidreuse()voidsetContentLength(long length)voidsetContentType(java.lang.String contentType)voidsetStatus(java.lang.String statusMsg)voidwriteHeader(java.io.OutputStream os)voidwriteTo(EndPoint endpoint)
-
-
-
Field Detail
-
ST_CONTINUE
public static final byte[] ST_CONTINUE
-
ST_SWITCHING_PROTOCOLS
public static final byte[] ST_SWITCHING_PROTOCOLS
-
ST_OK
public static final byte[] ST_OK
-
ST_CREATED
public static final byte[] ST_CREATED
-
ST_ACCEPTED
public static final byte[] ST_ACCEPTED
-
ST_NON_AUTHORITATIVE
public static final byte[] ST_NON_AUTHORITATIVE
-
ST_NO_CONTENT
public static final byte[] ST_NO_CONTENT
-
ST_RESET_CONTENT
public static final byte[] ST_RESET_CONTENT
-
ST_PARTIAL_CONTENT
public static final byte[] ST_PARTIAL_CONTENT
-
ST_MULTIPLE_CHOICES
public static final byte[] ST_MULTIPLE_CHOICES
-
ST_MOVED_PERMANENTLY
public static final byte[] ST_MOVED_PERMANENTLY
-
ST_FOUND
public static final byte[] ST_FOUND
-
ST_SEE_OTHER
public static final byte[] ST_SEE_OTHER
-
ST_NOT_MODIFIED
public static final byte[] ST_NOT_MODIFIED
-
ST_USE_PROXY
public static final byte[] ST_USE_PROXY
-
ST_TEMPORARY_REDIRECT
public static final byte[] ST_TEMPORARY_REDIRECT
-
ST_BAD_REQUEST
public static final byte[] ST_BAD_REQUEST
-
ST_UNAUTHORIZED
public static final byte[] ST_UNAUTHORIZED
-
ST_PAYMENT_REQUIRED
public static final byte[] ST_PAYMENT_REQUIRED
-
ST_FORBIDDEN
public static final byte[] ST_FORBIDDEN
-
ST_NOT_FOUND
public static final byte[] ST_NOT_FOUND
-
ST_METHOD_NOT_ALLOWED
public static final byte[] ST_METHOD_NOT_ALLOWED
-
ST_NOT_ACCEPTABLE
public static final byte[] ST_NOT_ACCEPTABLE
-
ST_PROXY_AUTHENTICATION_REQUIRED
public static final byte[] ST_PROXY_AUTHENTICATION_REQUIRED
-
ST_REQUEST_TIMEOUT
public static final byte[] ST_REQUEST_TIMEOUT
-
ST_CONFLICT
public static final byte[] ST_CONFLICT
-
ST_GONE
public static final byte[] ST_GONE
-
ST_LENGTH_REQUIRED
public static final byte[] ST_LENGTH_REQUIRED
-
ST_PRECONDITION_FAILED
public static final byte[] ST_PRECONDITION_FAILED
-
ST_REQUEST_ENTITY_TOO_LARGE
public static final byte[] ST_REQUEST_ENTITY_TOO_LARGE
-
ST_REQUEST_URI_TOO_LONG
public static final byte[] ST_REQUEST_URI_TOO_LONG
-
ST_UNSUPPORTED_MEDIA_TYPE
public static final byte[] ST_UNSUPPORTED_MEDIA_TYPE
-
ST_REQUEST_RANGE_NOT_SATISFIABLE
public static final byte[] ST_REQUEST_RANGE_NOT_SATISFIABLE
-
ST_EXPECTATION_FAILED
public static final byte[] ST_EXPECTATION_FAILED
-
ST_TEAPOT
public static final byte[] ST_TEAPOT
-
ST_INTERNAL_SERVER_ERROR
public static final byte[] ST_INTERNAL_SERVER_ERROR
-
ST_NOT_IMPLEMENTED
public static final byte[] ST_NOT_IMPLEMENTED
-
ST_BAD_GATEWAY
public static final byte[] ST_BAD_GATEWAY
-
ST_SERVICE_UNAVAILABLE
public static final byte[] ST_SERVICE_UNAVAILABLE
-
ST_GATEWAY_TIMEOUT
public static final byte[] ST_GATEWAY_TIMEOUT
-
ST_HTTP_VERSION_NOT_SUPPORTED
public static final byte[] ST_HTTP_VERSION_NOT_SUPPORTED
-
PROTOCOL
public static final byte[] PROTOCOL
-
F_SERVER
public static final byte[] F_SERVER
-
F_DATE
public static final byte[] F_DATE
-
CRLF
public static final byte[] CRLF
-
FIELD_SEP
public static final byte[] FIELD_SEP
-
byteCache
public static java.util.concurrent.ConcurrentHashMap<java.lang.String,byte[]> byteCache
-
status
public byte[] status
The status line for the response. Can use any of the predefined strings in HttpResponse.ST_*.
-
keys
public java.util.ArrayList<java.lang.String> keys
-
values
public java.util.ArrayList<java.lang.String> values
-
bodyStream
public ExposedBaos bodyStream
-
gmtdf
public static final java.text.SimpleDateFormat gmtdf
-
-
Method Detail
-
reuse
public void reuse()
-
setStatus
public void setStatus(java.lang.String statusMsg)
-
addField
public HttpResponse addField(java.lang.String key, java.lang.String value)
-
getHeaderValue
public java.lang.String getHeaderValue(java.lang.String key)
-
writeHeader
public void writeHeader(java.io.OutputStream os) throws java.io.IOException- Throws:
java.io.IOException
-
getOutputStream
public java.io.OutputStream getOutputStream()
-
writeTo
public void writeTo(EndPoint endpoint) throws java.io.IOException, Pausable
- Throws:
java.io.IOExceptionPausable
-
setContentLength
public void setContentLength(long length)
-
setContentType
public void setContentType(java.lang.String contentType)
-
-