|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openejb.webadmin.httpd.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 |
getResponseString()
Sets the response string to be sent to the browser |
String |
getServerName()
gets the name of the server being used |
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 |
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 backMethod Detail |
protected void setRequest(HttpRequestImpl request)
public void setHeader(String name, String value)
setHeader
in interface HttpResponse
name
- the name of the headervalue
- the value of the headerpublic String getHeader(String name)
getHeader
in interface HttpResponse
name
- The name of the header
public PrintWriter getPrintWriter()
getPrintWriter
in interface HttpResponse
public OutputStream getOutputStream()
getOutputStream
in interface HttpResponse
public void setCode(int code)
setCode
in interface HttpResponse
code
- the code to be sent to the browserpublic int getCode()
getCode
in interface HttpResponse
public void setContentType(String type)
setContentType
in interface HttpResponse
type
- the type to be sent to the browser (i.e. "text/html")public String getContentType()
getContentType
in interface HttpResponse
public void setResponseString(String responseString)
setResponseString
in interface HttpResponse
responseString
- the response stringpublic String getResponseString()
public void reset()
reset
in interface HttpResponse
public void reset(int code, String responseString)
reset
in interface HttpResponse
code
- the code to be sent to the browserresponseString
- the response string to be sent to the browserprotected void writeMessage(OutputStream output) throws IOException
output
- the output to send the response to
IOException
- if an exception is thrownpublic String toString()
public String getServerName()
getServerName
in interface HttpResponse
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.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |