DTA-CAB

 view release on metacpan or  search on metacpan

CAB/Server/HTTP/Handler.pm  view on Meta::CPAN

=over 4

=item L<DTA::CAB::Server::HTTP::Handler::CGI|DTA::CAB::Server::HTTP::Handler::CGI>

CAB HTTP Server: request handler: CGI form processing

=item L<DTA::CAB::Server::HTTP::Handler::Directory|DTA::CAB::Server::HTTP::Handler::Directory>

CAB HTTP Server: request handler: directory

=item L<DTA::CAB::Server::HTTP::Handler::File|DTA::CAB::Server::HTTP::Handler::File>

CAB HTTP Server: request handler: static file

=item L<DTA::CAB::Server::HTTP::Handler::Query|DTA::CAB::Server::HTTP::Handler::Query>

CAB HTTP Server: request handler: analyzer queries by CGI form

=item L<DTA::CAB::Server::HTTP::Handler::Response|DTA::CAB::Server::HTTP::Handler::Response>

CAB HTTP Server: request handler: static response

=item L<DTA::CAB::Server::HTTP::Handler::XmlRpc|DTA::CAB::Server::HTTP::Handler::XmlRpc>

CAB HTTP Server: request handler: XML-RPC queries (backwards-compatible)

=back

=cut

##----------------------------------------------------------------
## DESCRIPTION: DTA::CAB::Server::HTTP::Handler: API
=pod

=head2 API

=over 4

=item new

 $h = $class_or_obj->new(%options);

Create a new handler.
Default implementation just blesses \%options into the appropriate class.

=item prepare

 $bool = $h->prepare($server,$path);

Perfvorm server-dependent initialization for handler $h as called
by L<DTA::CAB::Server::HTTP|DTA::CAB::Server::HTTP> $srv
for path (string) $path.
Should return true on success.

Default implementation just returns true.

=item run

 $rsp = $h->run($server, $localPath, $clientConn, $httpRequest);

Run the handler to respond to an HTTP::Request $httpRequest
sent to the L<DTA::CAB::Server::HTTP|DTA::CAB::Server::HTTP> object $server
matching server path $localPath by the client socket $clientConn.

Should return a HTTP::Response object to pass to the client.
If the method call die()s or returns undef, an error response will be
sent to the client instead if it the connection is still open.

This method may return the data to the client itself; if so,
it should close the client connection ($csock-E<gt>shutdown(2); $csock-E<gt>close())
and return undef to prevent bogus error messages.

=item finish

 undef = $h->finish($server, $clientConn);

Clean up handler state after run().
Default implementation does nothing.

=back

=cut

##----------------------------------------------------------------
## DESCRIPTION: DTA::CAB::Server::HTTP::Handler: Generic Utilities
=pod

=head2 Generic Utilities

=over 4

=item headResponse

 $rsp = $h->headResponse();
 $rsp = $h->headResponse(\@headers)
 $rsp = $h->headResponse($httpHeaders)

Rudimentary handling for HEAD requests.

=item response

 $rsp = $CLASS_OR_OBJECT->response($code=RC_OK, $msg=status_message($code), $hdr, $content);

Creates and returns a new HTTP::Response.
$hdr may be a HTTP::Headers object, an array or hash-ref.
Really just a wrapper for HTTP::Response-E<gt>new().

=item cerror

 undef = $h->cerror($csock, $status=RC_INTERNAL_SERVER_ERROR, @msg);

Creates an error response and sends it to the client socket $csock.
Also logs the error at level ($h-E<gt>{logError}||'error') and shuts down the socket.

=item dumpResponse

 $rsp = $h->dumpResponse(\$contentRef, %opts);

Create and return a new data-dump response.
Known %opts:



( run in 0.459 second using v1.01-cache-2.11-cpan-5a3173703d6 )