org.mortbay.http

Class HttpResponse

public class HttpResponse extends HttpMessage

HTTP Response. This class manages the headers, trailers and content streams of a HTTP response. It can be used for receiving or generating requests. This class is not synchronized. It should be explicitly synchronized if it is used by multiple threads.

Version: $Id: HttpResponse.java,v 1.61 2005/10/26 08:10:14 gregwilkins Exp $

Author: Greg Wilkins (gregw)

See Also: HttpRequest

Field Summary
static int__100_Continue
static int__101_Switching_Protocols
static int__102_Processing
static int__200_OK
static int__201_Created
static int__202_Accepted
static int__203_Non_Authoritative_Information
static int__204_No_Content
static int__205_Reset_Content
static int__206_Partial_Content
static int__207_Multi_Status
static int__300_Multiple_Choices
static int__301_Moved_Permanently
static int__302_Found
static int__302_Moved_Temporarily
static int__303_See_Other
static int__304_Not_Modified
static int__305_Use_Proxy
static int__400_Bad_Request
static int__401_Unauthorized
static int__402_Payment_Required
static int__403_Forbidden
static int__404_Not_Found
static int__405_Method_Not_Allowed
static int__406_Not_Acceptable
static int__407_Proxy_Authentication_Required
static int__408_Request_Timeout
static int__409_Conflict
static int__410_Gone
static int__411_Length_Required
static int__412_Precondition_Failed
static int__413_Request_Entity_Too_Large
static int__414_Request_URI_Too_Large
static int__415_Unsupported_Media_Type
static int__416_Requested_Range_Not_Satisfiable
static int__417_Expectation_Failed
static int__422_Unprocessable_Entity
static int__423_Locked
static int__424_Failed_Dependency
static int__500_Internal_Server_Error
static int__501_Not_Implemented
static int__502_Bad_Gateway
static int__503_Service_Unavailable
static int__504_Gateway_Timeout
static int__505_HTTP_Version_Not_Supported
static int__507_Insufficient_Storage
static HashMap__statusMsg
Constructor Summary
HttpResponse()
Constructor.
HttpResponse(HttpConnection connection)
Constructor.
Method Summary
voidaddSetCookie(String name, String value)
Add a Set-Cookie field.
voidaddSetCookie(Cookie cookie)
Add a Set-Cookie field.
voidcommit()
voidcompleting()
voiddestroy()
Destroy the response.
HttpContextgetHttpContext()
Get the HttpContext handling this reponse.
HttpRequestgetHttpRequest()
Get the HTTP Request.
StringgetReason()
HttpRequestgetRequest()
intgetStatus()
booleanisDirty()
voidreadHeader(HttpInputStream in)
Not Implemented.
voidreset()
Reset the response.
voidsendError(int code, String message)
Send Error Response.
voidsendError(int code)
Sends an error response to the client using the specified status code and no default message.
voidsendRedirect(String location)
Sends a redirect response to the client using the specified redirect location URL.
voidsetHttpContext(HttpContext context)
Set the HttpContext handling this reponse.
voidsetReason(String reason)
voidsetStatus(int status)
voidsetStatus(int code, String message)
voidwriteHeader(Writer writer)

Field Detail

__100_Continue

public static final int __100_Continue

__101_Switching_Protocols

public static final int __101_Switching_Protocols

__102_Processing

public static final int __102_Processing

__200_OK

public static final int __200_OK

__201_Created

public static final int __201_Created

__202_Accepted

public static final int __202_Accepted

__203_Non_Authoritative_Information

public static final int __203_Non_Authoritative_Information

__204_No_Content

public static final int __204_No_Content

__205_Reset_Content

public static final int __205_Reset_Content

__206_Partial_Content

public static final int __206_Partial_Content

__207_Multi_Status

public static final int __207_Multi_Status

__300_Multiple_Choices

public static final int __300_Multiple_Choices

__301_Moved_Permanently

public static final int __301_Moved_Permanently

__302_Found

public static final int __302_Found

__302_Moved_Temporarily

public static final int __302_Moved_Temporarily

__303_See_Other

public static final int __303_See_Other

__304_Not_Modified

public static final int __304_Not_Modified

__305_Use_Proxy

public static final int __305_Use_Proxy

__400_Bad_Request

public static final int __400_Bad_Request

__401_Unauthorized

public static final int __401_Unauthorized

__402_Payment_Required

public static final int __402_Payment_Required

__403_Forbidden

public static final int __403_Forbidden

__404_Not_Found

public static final int __404_Not_Found

__405_Method_Not_Allowed

public static final int __405_Method_Not_Allowed

__406_Not_Acceptable

public static final int __406_Not_Acceptable

__407_Proxy_Authentication_Required

public static final int __407_Proxy_Authentication_Required

__408_Request_Timeout

public static final int __408_Request_Timeout

__409_Conflict

public static final int __409_Conflict

__410_Gone

public static final int __410_Gone

__411_Length_Required

public static final int __411_Length_Required

__412_Precondition_Failed

public static final int __412_Precondition_Failed

__413_Request_Entity_Too_Large

public static final int __413_Request_Entity_Too_Large

__414_Request_URI_Too_Large

public static final int __414_Request_URI_Too_Large

__415_Unsupported_Media_Type

public static final int __415_Unsupported_Media_Type

__416_Requested_Range_Not_Satisfiable

public static final int __416_Requested_Range_Not_Satisfiable

__417_Expectation_Failed

public static final int __417_Expectation_Failed

__422_Unprocessable_Entity

public static final int __422_Unprocessable_Entity

__423_Locked

public static final int __423_Locked

__424_Failed_Dependency

public static final int __424_Failed_Dependency

__500_Internal_Server_Error

public static final int __500_Internal_Server_Error

__501_Not_Implemented

public static final int __501_Not_Implemented

__502_Bad_Gateway

public static final int __502_Bad_Gateway

__503_Service_Unavailable

public static final int __503_Service_Unavailable

__504_Gateway_Timeout

public static final int __504_Gateway_Timeout

__505_HTTP_Version_Not_Supported

public static final int __505_HTTP_Version_Not_Supported

__507_Insufficient_Storage

public static final int __507_Insufficient_Storage

__statusMsg

public static final HashMap __statusMsg

Constructor Detail

HttpResponse

public HttpResponse()
Constructor.

HttpResponse

public HttpResponse(HttpConnection connection)
Constructor.

Parameters: connection

Method Detail

addSetCookie

public void addSetCookie(String name, String value)
Add a Set-Cookie field.

addSetCookie

public void addSetCookie(Cookie cookie)
Add a Set-Cookie field.

commit

public void commit()

Throws: IOException

completing

public void completing()

destroy

public void destroy()
Destroy the response. Help the garbage collector by null everything that we can.

getHttpContext

public HttpContext getHttpContext()
Get the HttpContext handling this reponse.

Returns: The HttpContext that is handling this request.

getHttpRequest

public HttpRequest getHttpRequest()
Get the HTTP Request. Get the HTTP Request associated with this response.

Returns: associated request

getReason

public String getReason()

getRequest

public HttpRequest getRequest()

Deprecated: use getHttpRequest()

getStatus

public int getStatus()

isDirty

public boolean isDirty()

Returns: true if the message has been modified.

readHeader

public void readHeader(HttpInputStream in)
Not Implemented.

Parameters: in

Throws: IOException

reset

public void reset()
Reset the response. Clears any data that exists in the buffer as well as the status code. If the response has been committed, this method throws an IllegalStateException.

Throws: IllegalStateException if the response has already been committed

sendError

public void sendError(int code, String message)
Send Error Response.

sendError

public void sendError(int code)
Sends an error response to the client using the specified status code and no default message.

Parameters: code the status code

Throws: IOException If an I/O error has occurred.

sendRedirect

public void sendRedirect(String location)
Sends a redirect response to the client using the specified redirect location URL.

Parameters: location the redirect location URL

Throws: IOException If an I/O error has occurred.

setHttpContext

public void setHttpContext(HttpContext context)
Set the HttpContext handling this reponse.

Parameters: context The HttpContext handling this reponse.

setReason

public void setReason(String reason)

setStatus

public void setStatus(int status)

setStatus

public void setStatus(int code, String message)

writeHeader

public void writeHeader(Writer writer)
Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.