| java.lang.Object net.homeip.donaldm.httpdbase4j.HttpResponse
HttpResponse | public class HttpResponse (Code) | | Encapsulates sending HTTP responses and provides several static methods
for sending common HTTP error and informational responses.
author: Donald Munro |
Method Summary | |
public static HttpResponse | accessDenied(HttpExchange exchange, URI uri, Headers requestHeaders) | public void | addHeader(String k, String v) Add a header value. | public String | getHeader(String k) Get a header value that was set for this response. | public String | getHeader(String k, int index) Get a header value that was set for this response.
Parameters: k - The header key Parameters: index - If there is more than one value for the header key then return the kth value. | public static HttpResponse | internalError(HttpExchange exchange, URI uri, Headers requestHeaders) | public static HttpResponse | notFound(HttpExchange exchange, URI uri, Headers requestHeaders) | public static HttpResponse | notifyContinue(HttpExchange exchange) Create a HTTP NOTIFY CONTINUE response
Parameters: exchange - The exchange instance for the current HTTP transaction. | public static HttpResponse | reDirect(HttpExchange exchange, URI uri, Headers requestHeaders) | public boolean | send() Send the Response using the body and/or status previously specified in the
constructor. | public boolean | sendData() | public boolean | sendData(String s) Send the Response data
Parameters: s - The string to send as the Response body. | public boolean | sendData(InputStream data) Send the Response data
Parameters: data - The stream to send as the Response body. | public boolean | sendHeaders() | public boolean | sendHeaders(long contentLength) Send the Response headers
Parameters: contentLength - The content length for the body text that will be sent with sendData. | public void | setBody(String body) | public void | setMimeType(String mimeType) | public void | setStatus(int status) |
m_exchange | protected HttpExchange m_exchange(Code) | | |
m_headers | protected Headers m_headers(Code) | | |
m_status | protected int m_status(Code) | | |
HttpResponse | public HttpResponse(HttpExchange exchange)(Code) | | Create a HttpResponse
Parameters: exchange - The exchange instance for the current HTTP transaction. |
HttpResponse | public HttpResponse(HttpExchange exchange, int status)(Code) | | Create a HttpResponse
Parameters: exchange - The exchange instance for the current HTTP transaction. Parameters: status - The HTTP status code of the response |
HttpResponse | public HttpResponse(HttpExchange exchange, int status, String mimeType)(Code) | | Create a HttpResponse
Parameters: exchange - The exchange instance for the current HTTP transaction. Parameters: status - The HTTP status code of the response Parameters: mimeType - The mime type for the response |
HttpResponse | public HttpResponse(HttpExchange exchange, int status, String mimeType, String body)(Code) | | Create a HttpResponse
Parameters: exchange - The exchange instance for the current HTTP transaction. Parameters: status - The HTTP status code of the response Parameters: mimeType - The mime type for the response Parameters: body - The content of the response |
accessDenied | public static HttpResponse accessDenied(HttpExchange exchange, URI uri, Headers requestHeaders)(Code) | | Create a HTTP ACCESS DENIED response
Parameters: exchange - The exchange instance for the current HTTP transaction. Parameters: uri - The URI for the response Parameters: requestHeaders - The request headers An HttpResponse instance |
addHeader | public void addHeader(String k, String v)(Code) | | Add a header value.
Parameters: k - The header key to add a value for Parameters: v - The header value |
getHeader | public String getHeader(String k)(Code) | | Get a header value that was set for this response.
Parameters: k - The header key The header string for key k |
getHeader | public String getHeader(String k, int index)(Code) | | Get a header value that was set for this response.
Parameters: k - The header key Parameters: index - If there is more than one value for the header key then return the kth value. The header for key k and index index |
internalError | public static HttpResponse internalError(HttpExchange exchange, URI uri, Headers requestHeaders)(Code) | | Create a HTTP INTERNAL ERROR response
Parameters: exchange - The exchange instance for the current HTTP transaction. Parameters: uri - The URI for the response Parameters: requestHeaders - The request headers An HttpResponse instance |
notFound | public static HttpResponse notFound(HttpExchange exchange, URI uri, Headers requestHeaders)(Code) | | Create a HTTP NOT FOUND response
Parameters: exchange - The exchange instance for the current HTTP transaction. Parameters: uri - The URI for the response Parameters: requestHeaders - The request headers An HttpResponse instance |
notifyContinue | public static HttpResponse notifyContinue(HttpExchange exchange)(Code) | | Create a HTTP NOTIFY CONTINUE response
Parameters: exchange - The exchange instance for the current HTTP transaction. An HttpResponse instance |
reDirect | public static HttpResponse reDirect(HttpExchange exchange, URI uri, Headers requestHeaders)(Code) | | Create a HTTP REDIRECT response
Parameters: exchange - The exchange instance for the current HTTP transaction. Parameters: uri - The URI for the response Parameters: requestHeaders - The request headers An HttpResponse instance |
send | public boolean send()(Code) | | Send the Response using the body and/or status previously specified in the
constructor. If the body is not specified then nol content is send only
the headers.
true if Response was successfully sent otherwise false |
sendData | public boolean sendData()(Code) | | Send the Response data
true if Response was successfully sent otherwise false |
sendData | public boolean sendData(String s)(Code) | | Send the Response data
Parameters: s - The string to send as the Response body. Note: This must be the same length as the contentLength set in sendHeaders. true if Response was successfully sent otherwise false |
sendData | public boolean sendData(InputStream data)(Code) | | Send the Response data
Parameters: data - The stream to send as the Response body. Note: This must be the same length as the contentLength set in sendHeaders. true if Response was successfully sent otherwise false |
sendHeaders | public boolean sendHeaders()(Code) | | Send the Response headers
true if successful otherwise false |
sendHeaders | public boolean sendHeaders(long contentLength)(Code) | | Send the Response headers
Parameters: contentLength - The content length for the body text that will be sent with sendData. If contentLength is -1 then the length of the bodyset in the constructor will be used true if successfull otherwise false |
setStatus | public void setStatus(int status)(Code) | | |
|
|