|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.openejb.server.httpd.HttpResponseImpl
public class HttpResponseImpl
This class takes care of HTTP Responses. It sends data back to the browser.
| Field Summary | |
|---|---|
static String |
CRLF
a line feed character |
static String |
CSP
a colon and space |
static String |
HTTP_VERSION
the HTTP version |
static String |
server
the server to send data from |
static String |
SP
a space character |
| Constructor Summary | |
|---|---|
protected |
HttpResponseImpl()
creates a new instance of HttpResponseImpl with default values |
protected |
HttpResponseImpl(int code,
String responseString,
String contentType)
Creates a new HttpResponseImpl with user provided parameters |
| Method Summary | |
|---|---|
protected static HttpResponseImpl |
createError(String message)
This could be improved at some day in the future to also include a stack trace of the exceptions |
protected static HttpResponseImpl |
createError(String message,
Throwable t)
creates an error with user defined variables |
protected static HttpResponseImpl |
createForbidden(String ip)
Creates a forbidden response to be sent to the browser using IP authentication |
int |
getCode()
gets the HTTP response code |
String |
getContentType()
gets the content type that will be sent to the browser |
String |
getHeader(String name)
Gets a header based on the name passed in |
OutputStream |
getOutputStream()
gets the OutputStream to send data to the browser |
PrintWriter |
getPrintWriter()
Gets the PrintWriter to send data to the browser |
String |
getServerName()
gets the name of the server being used |
int |
getStatusCode()
gets the HTTP response code |
void |
reset()
resets the data to be sent to the browser |
void |
reset(int code,
String responseString)
resets the data to be sent to the browser with the response code and response string |
void |
setCode(int code)
sets the HTTP response code to be sent to the browser. |
void |
setContent(URLConnection content)
|
void |
setContentType(String type)
sets the content type to be sent back to the browser |
void |
setHeader(String name,
String value)
sets a header to be sent back to the browser |
protected void |
setRequest(HttpRequestImpl request)
|
void |
setResponseString(String responseString)
Sets the response string to be sent to the browser |
void |
setStatusCode(int code)
sets the HTTP response code to be sent to the browser. |
void |
setStatusMessage(String responseString)
Sets the response string to be sent to the browser |
String |
toString()
Creates a string version of the response similar to: HTTP/1.1 200 OK |
protected void |
writeMessage(OutputStream output)
Takes care of sending the response line, headers and body HTTP/1.1 200 OK Server: Netscape-Enterprise/3.6 SP3 Date: Thu, 07 Jun 2001 17:30:42 GMT Content-Type: text/html Connection: close |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String HTTP_VERSION
public static final String CRLF
public static final String SP
public static final String CSP
public static String server
| Constructor Detail |
|---|
protected HttpResponseImpl()
protected HttpResponseImpl(int code,
String responseString,
String contentType)
code - the HTTP Response code, see http://www.ietf.org/rfc/rfc2616.txt
for these codesresponseString - the response string to be sent backcontentType - the content type to be sent back| Method Detail |
|---|
protected void setRequest(HttpRequestImpl request)
public void setHeader(String name,
String value)
setHeader in interface HttpResponsename - the name of the headervalue - the value of the headerpublic String getHeader(String name)
getHeader in interface HttpResponsename - The name of the header
public PrintWriter getPrintWriter()
getPrintWriter in interface HttpResponsepublic OutputStream getOutputStream()
getOutputStream in interface HttpResponsepublic void setCode(int code)
code - the code to be sent to the browserpublic int getCode()
public void setContentType(String type)
setContentType in interface HttpResponsetype - the type to be sent to the browser (i.e. "text/html")public String getContentType()
getContentType in interface HttpResponsepublic void setResponseString(String responseString)
responseString - the response stringpublic void reset()
public void reset(int code,
String responseString)
code - the code to be sent to the browserresponseString - the response string to be sent to the browser
protected void writeMessage(OutputStream output)
throws IOException
output - the output to send the response to
IOException - if an exception is thrownpublic String toString()
toString in class Objectpublic String getServerName()
protected static HttpResponseImpl createError(String message)
message - the error message to be sent
protected static HttpResponseImpl createError(String message,
Throwable t)
message - the message of the errort - a Throwable to print a stack trace to
protected static HttpResponseImpl createForbidden(String ip)
ip - the ip that is forbidden
public void setContent(URLConnection content)
content - The content to set.public void setStatusCode(int code)
HttpResponse
setStatusCode in interface HttpResponsecode - the code to be sent to the browserpublic int getStatusCode()
HttpResponse
getStatusCode in interface HttpResponsepublic void setStatusMessage(String responseString)
HttpResponse
setStatusMessage in interface HttpResponseresponseString - the response string
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||