Jerome Eteve > Apache2-REST-0.07 > Apache2::REST::WriterMultipart

Download:
Apache2-REST-0.07.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

new

You can override this if you like but remember it has to build an object without arguments.

mimeType

Returns the mime type this writer will output.

It is called like this by the framework:

   $this->mimeType($resp) ;

This defaults to multipart/x-mixed-replace (makes it easy to test in the browser) but can be overridden. For example, one might want to use plain multipart/mixed.

getPreambleBytes

Returns the bytes the framework has to write back to client as a Stream preamble. This defaults to "" for the multipart writer since data typically isn't send with the initial response (it doesn't really have a formal mime type at that point). Normally the first relevant content is the first "part" which comes with it's own headers.

It is called by the framework like this ($resp is a Apache2::REST::Response):

    $this->getPreambleBytes($resp) ;

getNextPart

Returns the next part of the multipart response, or undef at the end of the stream. The chunk should be a hash containing 'mimetype' and 'data'. This allows the subclass to dictate the mimetype of every chunk and, thus, they can all be different if desired (an xml doc, then an audio file for ex.).

Called by the framework like that:

while( defined my $chunk = $this->getNextChunk($response) ){ my $mimetype = $chunk->{'mimetype'}; my $bytes = $chunk->{'data'}; ... }

getPostambleBytes

Returns the last bytes to write in the stream when the stream is finished. This defaults to "" for the multipart writer and probably shouldn't be changed since it would sandwhich data between the final chunk and the final boundary string.

Called by the framework like that:

$this->getPostambleBytes($response);

handleModPerlResponse

Handles writing this response in a mod perl request object at response time. This also handles the additional work of crafting the correct multipart boundaries, etc.

Beware, this method switches STDOUT to binmode.

syntax highlighting: