NAME

Wombat::Connector::ResponseBase - internal response base class


SYNOPSIS

  package My::Connector::Response;
  use base qw(Wombat::Connector::ResponseBase);


DESCRIPTION

Convenience base implementation of Wombat::Response and Servlet::ServletResponse which can be used for most connectors. Only connector-specific methods need to be implemented.


CONSTRUCTOR

new()
Construct and return a Wombat::Connector::ResponseBase instance, initializing fields appropriately. If subclasses override the constructor, they must be sure to call
  $self->SUPER::new();


ACCESSOR METHODS

getApplication()
Return the Application within which this Response is being generated.

setApplication($application)
Set the Application within which this Response is being generated. This must be called as soon as the appropriate Application is identified.

Parameters:

$application
the Wombat::Application within which the Response is being generated

getBufferSize()
Return the buffer size (in bytes) used for the response.

setBufferSize($size)
Set the preferred buffer size for the body of the response.

Parameters:

$size
the buffer size, in bytes

Throws:

Servlet::Util::IllegalStateException
if content has been written to the buffer

getCharacterEncoding()
Return the character encoding used in the body of this Response, or ISO-8859-1 if the character encoding is unset. The character encoding is set explicitly with setContentType() or implicity with setLocale().

isCommitted()
Return a flag indicating if this Response has been committed.

getConnector()
Return the Connector through which this Response is returned.

setConnector($connector)
Set the Connector through which this response is returned.

Parameters:

$connector
the Wombat::Connector that will return the response

getContentCount()
Return the number of bytes actually written to the output handle.

getContentLength()
Return the content length, in bytes, that was set or calculated for this Response.

setContentLength($len)
Set the length of the content body in this Response.

Parameters:

$len
the content length, in bytes

getContentType()
Return the MIME type that was set or calculated for this response.

setContentType($type)
Set the content type of this Response. If the charset parameter is specified, the character encoding of this Response is also set.

Parameters:

$type
the MIME type of the content

isError()
Return a flag indicating whether or not this is an error response.

setError()
Set a flag indicating that this Response is an error response.

getHandle()
Return the output handle associated with this Response.

setHandle($handle)
Set the output handle ssociated with this Response.

Parameters:

$handle
the IO::Handle associated with this response

isIncluded()
Return a flag indicating whether or not this Response is being processed as an include.

setIncluded($flag)
Set a flag indicating whether or not this Response is being processed as an include.

Parameters:

$flag
a boolean value indicating whether or not this response is included

getLocale()
Return the locale assigned to this Response.

setLocale($loc)
Set the locale for this Response. The character encoding for this Response will be set to the encoding specified by the locale.

Parameters:

$loc
the locale for the response

getOutputHandle()
Return the Servlet::ServletOutputHandle that wraps the underlying output handle (see getHandle(). The default implementation returns a handle created by createOutputHandle().

Throws:

Servlet::Util::IllegalStateException
if the getWriter() method has already been called for this response

Servlet::Util::IOException
if an input or output exception occurred

getRequest()
Return the Request with which this Response is associated.

setRequest($request)
Set the Request with which this Response is associated.

Parameters:

$request
the Wombat::Request with which this response is associated

getResponse()
Return the ServletResponse for which this object is the facade.

getWriter()
Return the XXX that wraps the ServletOutputHandle for this response. The default implementation returns a XXX wrapped around the handle created by createOutputHandle().

Throws:

Servlet::Util::UnsupportedEncodingException
if the charset specified in setContentType() cannot be used

Servlet::Util::IllegalStateException
if the getOutputHandle() method has already been called for this request

Servlet::Util::IOException
if an input or output exception occurred


PUBLIC METHODS

createOutputHandle()
Create and return a Servlet::ServletOutputHandle to write the response content.

Throws:

Servlet::Util::IOException
if an input or output error occurs

finishResponse()
Perform whatever actions are required to flush and close the output handle or writer.

Throws:

Servlet::Util::IOException
if an input or output error occurs

flushBuffer()
Force any content in the buffer to be written to the client. The response is automatically committed on the first invocation of this method.

Throws:

Servlet::Util::IOException
reset()
Clear any data that exists in the content buffer and unset the content length and content type.

Throws:

Servlet::Util::IllegalStateException
if the response has already been committed

resetBuffer()
Clear the content of the content buffer in the response without modifying any other fields.

Throws:

Servlet::Util::IllegalStateException
if the response has already been committed


PACKAGE METHODS

These methods should only ever be called by other classes in the Wombat::Connector namespace. Other packages should use the public API only!

write($string, [$length, [$offset]])
Write the specified string to the content buffer and return the number of bytes written. If the operation causes the buffer to be filled, the buffer will be flushed (as many times as necessary).

recycle()
Release all object references and initialize instances variables in preparation for use or reuse of this object.


SEE ALSO

the IO::Handle manpage, the Servlet::ServletResponse manpage, the Servlet::ServletServletOutputHandle manpage, the Servlet::Util::Exception manpage, the Wombat::Application manpage, the Wombat::Connector manpage, the Wombat::Request manpage, the Wombat::Response manpage


AUTHOR

Brian Moseley, bcm@maz.org