|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object seda.sandStorm.lib.http.httpResponse
public abstract class httpResponse
This is an abstract class corresponding to an HTTP response. Use one of the subclasses (such as httpOKResponse or httpNotFoundResponse) to push responses back to the client.
httpOKResponse
,
httpNotFoundResponse
Field Summary | |
---|---|
protected int |
code
The code corresponding to the response. |
protected BufferElement |
combinedData
The actual data of the response. |
protected int |
contentLength
The content-length header. |
protected java.lang.String |
contentType
The MIME type of the response. |
private static boolean |
DEBUG
|
static java.lang.String |
DEFAULT_MIME_TYPE
The default MIME type for responses, which is "text/html". |
protected static java.lang.String |
defaultHeader
The default response header. |
protected BufferElement |
header
The header for the response. |
protected BufferElement |
payload
The payload for the response. |
static int |
RESPONSE_BAD_REQUEST
Code corresponding to '400 Bad Request'. |
static int |
RESPONSE_INTERNAL_SERVER_ERROR
Code corresponding to '500 Internal Server Error'. |
static int |
RESPONSE_NOT_FOUND
Code corresponding to '404 Not Found'. |
static int |
RESPONSE_OK
Code corresponding to '200 OK'. |
static int |
RESPONSE_REDIRECT
Code corresponding to '301 Moved Permanently'. |
static int |
RESPONSE_SERVICE_UNAVAILABLE
Code corresponding to '503 Service Unavailable'. |
Fields inherited from interface seda.sandStorm.lib.http.httpConst |
---|
CRLF, DEFAULT_HTTP_PORT, HTTP_VERSION, WRITE_CLOG_THRESHOLD |
Constructor Summary | |
---|---|
protected |
httpResponse(int code,
java.lang.String contentType)
Create an httpResponse with the given response code with no payload. |
protected |
httpResponse(int code,
java.lang.String contentType,
BufferElement payload)
Create an httpResponse with the given response code with the given payload. |
protected |
httpResponse(int code,
java.lang.String contentType,
BufferElement payload,
int contentLength)
Create an httpResponse with the given response code with the given payload. |
protected |
httpResponse(int code,
java.lang.String contentType,
int payloadSize)
Create an httpResponse with the the given response code, with an empty payload of the given size. |
protected |
httpResponse(int code,
java.lang.String contentType,
int payloadSize,
SinkIF compQ)
Create an httpResponse with the the given response code, with an empty payload of the given size. |
Method Summary | |
---|---|
private java.lang.String |
genHeader()
Generate the header. |
BufferElement[] |
getBuffers(boolean sendHeader)
Get an array of BufferElements corresponding to this response. |
static java.lang.String |
getDefaultHeader()
Return the default header string sent in all responses. |
protected abstract java.lang.String |
getEntityHeader()
Return the entity header as a String. |
BufferElement |
getHeader()
Returns the header for this response. |
BufferElement |
getPayload()
Returns the payload for this response. |
static void |
setDefaultHeader(java.lang.String defhdr)
Set the default header string sent in all responses. |
void |
setPayload(BufferElement payload)
Used to set the payload after creating the response with an empty payload. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int RESPONSE_OK
public static final int RESPONSE_REDIRECT
public static final int RESPONSE_BAD_REQUEST
public static final int RESPONSE_NOT_FOUND
public static final int RESPONSE_INTERNAL_SERVER_ERROR
public static final int RESPONSE_SERVICE_UNAVAILABLE
public static final java.lang.String DEFAULT_MIME_TYPE
private static final boolean DEBUG
protected int code
protected static java.lang.String defaultHeader
protected BufferElement combinedData
protected BufferElement header
protected BufferElement payload
protected java.lang.String contentType
protected int contentLength
Constructor Detail |
---|
protected httpResponse(int code, java.lang.String contentType, BufferElement payload)
code
- The response code; should be one of the constants
from httpResponse.RESPONSE_*.contentType
- The MIME type of the response content. Should
not be CRLF-terminated.payload
- The payload of the response.protected httpResponse(int code, java.lang.String contentType, BufferElement payload, int contentLength)
code
- The response code; should be one of the constants
from httpResponse.RESPONSE_*.contentType
- The MIME type of the response content. Should
not be CRLF-terminated.payload
- The payload of the response.contentLength
- The contentLength to place in the header.protected httpResponse(int code, java.lang.String contentType)
code
- The response code; should be one of the constants
from httpResponse.RESPONSE_*.contentType
- The MIME type of the response content. Should
not be CRLF-terminated.payload
- The payload of the response.protected httpResponse(int code, java.lang.String contentType, int payloadSize, SinkIF compQ)
code
- The response code; should be one of the constants
from httpResponse.RESPONSE_*.contentType
- The MIME type of the response content. Should
not be CRLF-terminated.payloadSize
- The size of the payload to allocate.compQ
- The completion queue for the payload.protected httpResponse(int code, java.lang.String contentType, int payloadSize)
code
- The response code; should be one of the constants
from httpResponse.RESPONSE_*.contentType
- The MIME type of the response content. Should
not be CRLF-terminated.payloadSize
- The size of the payload to allocate.Method Detail |
---|
protected abstract java.lang.String getEntityHeader()
public void setPayload(BufferElement payload)
public BufferElement getHeader()
public BufferElement getPayload()
public static void setDefaultHeader(java.lang.String defhdr)
public static java.lang.String getDefaultHeader()
private java.lang.String genHeader()
public BufferElement[] getBuffers(boolean sendHeader)
sendHeader
- Indicate whether the header should be included.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |