Net::IMP::HTTP::Base - base class for HTTP connection specific IMP plugins
use base 'Net::IMP::HTTP::Request';
# implement methods for the various parts of an HTTP traffic
sub request_hdr ...
sub request_body ...
sub response_hdr ...
sub response_body ...
sub any_data ...
Net::IMP::HTTP::Request is a base class for HTTP request specific IMP plugins. It provides a way to use such plugins in HTTP aware applications, like App::HTTP_Proxy_IMP, but with the help of Net::IMP::Adaptor::STREAM2HTTPReq also in applications using only an untyped data stream.
Return values are the same as in other IMP plugins but are all related to the request. This means especially, that IMP_MAXOFFSET means end of request, not end of HTTP connection.
You can either redefine the data method (common to all IMP plugins) or use the default implementation, which dispatches to various method based on the type of the received data. In this case you need to implement:
This method gets the header of the HTTP request.
This method is called for parts of the request body. For the final part it will be called with $data set to ''.
This method gets the header of the HTTP response.
This method is called for parts of the response body. For the final part it will be called with $data set to ''.
This method gets called on all data chunks after connection upgrades (e.g. Websocket, CONNECT request...). For end of data '' is send as $data.
If you use the default implementation of data you can also use the method offset(dir) to find out the current offset (e.g. position in byte stream after the given data).
Also an RTYPES method should be implemented for the factory object and return a list of the supported return types. These will be used to construct the proper interface method.
To install Net::IMP::HTTP, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.