Net::IMP::HTTP::Connection(3p)

NAME
Net::IMP::HTTP::Connection - base class for HTTP connection specific IMP plugins

SYNOPSIS
    package myHTTPAnalyzer;
    use base 'Net::IMP::HTTP::Connection';

    # implement methods for the various parts of an HTTP traffic
    sub request_hdr ...
    sub request_body ...
    sub response_hdr ...
    sub response_body ...
    sub rsp_chunk_hdr ...
    ...

DESCRIPTION
Net::IMP::HTTP::Connection is a base class for HTTP connection 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::STREAM2HTTPConn also in applications using only an untyped data stream.

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:

request_hdr($self,$hdr)
    This method gets the header of the HTTP request.

request_body($self,$data,[$offset])
    This method is called for parts of the request body. For the final part it will be called with $data set to ''.

response_hdr($self,$hdr)
    This method gets the header of the HTTP response.

response_body($self,$data,[$offset])
    This method is called for parts of the response body. For the final part it will be called with $data set to ''.

rsp_chunk_hdr($self,$hdr)
    This method gets called with the chunk header on chunked transfer encoding of the body.

rsp_chunk_trailer($self,$hdr)
    This method gets called with the chunk trailer on chunked transfer encoding of the body. Will not be called, if there is no trailer.

any_data($self,$dir,$data,[$offset])
    This method gets called on all data chunks after connection upgrades (e.g. Websocket, CONNECT request...). For end of data '' is send as $data.

junk_data($self,$dir,$data,[$offset])
    This method gets called on junk data (e.g. newlines before request etc), which are allowed for HTTP but have no semantic. The default implementation does nothing with these 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.