|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--jason.framework.protocol.http.HttpResponseBuilderImpl
Created Thu Jan 3 13:11:22 2002
This classe is responsable to build a valid HTTP response. User
must set parameters and call the build
method for
a valid response.
Here a short desciption of an HTTP response from the RFC 2068 :
generic-message = start-line *message-header CRLF [ message-body ] start-line = Request-Line | Status-Line Request-Line = Method SP Request-URI SP HTTP-Version CRLF Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF
Constructor Summary | |
HttpResponseBuilderImpl(HttpRequestParser parser)
Build an HttpResponseBuilder with the opponent request parser value |
|
HttpResponseBuilderImpl(HttpRequestParser parser,
int status)
Build an HttpResponseBuilderImpl with the opponent request parser value and a status code |
Method Summary | |
protected void |
buildMessageBodyResponse(java.io.OutputStream output)
Add the message body part (look at the class header) |
protected void |
buildMessageHeaderResponse(java.io.PrintWriter pw)
Build a response with the message-header parser (look at the class header) |
protected void |
buildRequestLineResponse(java.io.PrintWriter pw)
Request-Line = Method SP Request-URI SP HTTP-Version CRLF Build a response for the Request-Line rule (look at the class header) |
void |
buildResponse(java.io.OutputStream output)
Build a response from the output stream with the browser |
protected void |
buildStatusLineResponse(java.io.PrintWriter pw)
Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF Build a response for the Status-Line rule (look at the class header) |
void |
setContent(byte[] content)
Set the content of the [message-body] part |
protected void |
setContentLength(int length)
Reset the content-length, it should be coherent with the
setContent call. |
void |
setContentType(java.lang.String type)
Reset the content-type of the content message-body part |
void |
setMessageHeader(java.lang.String field,
java.lang.String value)
Stores a message Header that will be sent with the HTTP response (look at the class header for the rule) |
void |
setServer(java.lang.String server)
Set the server name for the response |
void |
setStatusCode(int statusCode)
A statusCode should be >= 100 and <= 505 |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public HttpResponseBuilderImpl(HttpRequestParser parser)
public HttpResponseBuilderImpl(HttpRequestParser parser, int status)
Method Detail |
public void setStatusCode(int statusCode)
setStatusCode
in interface HttpResponseBuilder
public void buildResponse(java.io.OutputStream output) throws java.io.IOException
buildResponse
in interface HttpResponseBuilder
java.io.IOException
protected void buildMessageHeaderResponse(java.io.PrintWriter pw) throws java.io.IOException
java.io.IOException
protected void buildStatusLineResponse(java.io.PrintWriter pw) throws java.io.IOException
Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF
java.io.IOException
protected void buildRequestLineResponse(java.io.PrintWriter pw) throws java.io.IOException
Request-Line = Method SP Request-URI SP HTTP-Version CRLF
java.io.IOException
protected void buildMessageBodyResponse(java.io.OutputStream output) throws java.io.IOException
java.io.IOException
public void setMessageHeader(java.lang.String field, java.lang.String value)
setMessageHeader
in interface HttpResponseBuilder
public void setContentType(java.lang.String type)
setContentType
in interface HttpResponseBuilder
type
- is a MIME type (text/html for instance)protected void setContentLength(int length)
setContent
call. Note that this last method resets itself
this field, you theorically have no reason to reset it
public void setContent(byte[] content)
setContent
in interface HttpResponseBuilder
public void setServer(java.lang.String server)
setServer
in interface HttpResponseBuilder
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |