Net-IMP-HTTP

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

- remove use of obsolete smartmatch operator
0.523 2014/12/09
- move SaveResponse and LogFormData to Example
- fix smartmatch warnings
- fix MANIFEST
0.521 2013/06/28
- support for IMP_FATAL, added with Net::IMP 0.617
0.52 2013/03/03
- new plugin Example::BlockContentType
- reworked FlipIMG
  use Image::Magick instead of Graphics::Magick (because of crash of Graphics::Magick)
0.51 2013/02/19
- adapted FlipImg to send pass with maxoffset after replacement at end of body
- make load of SaveResponse in t/01_load.t depend on File::Path version
- skip t/05_logformdata.t if we cannot load LogFormData
0.5 2013/01/22
- new plugin SaveResponse
- use Data::Dumper::Sortkeys in tests to make comparing results more reliable
0.4 2013/01/17
- fix test t/05_logformdata.t in case neither YAML nor YAML::Tiny is installed
0.3 2013/01/15

lib/Net/IMP/HTTP/Example/FlipImg.pm  view on Meta::CPAN


package Net::IMP::HTTP::Example::FlipImg;
use base 'Net::IMP::HTTP::Request';
use fields (
    'ignore',  # irrelevant content
    'image',   # collected octets for image
);

use Net::IMP;  # import IMP_ constants
use Net::IMP::Debug;
use Image::Magick;
use constant MAX_SIZE => 2**16;

sub RTYPES { ( IMP_PASS, IMP_REPLACE ) }
sub new_analyzer {
    my ($factory,%args) = @_;
    my $self = $factory->SUPER::new_analyzer(%args);
    # request data do not matter
    $self->run_callback([ IMP_PASS,0,IMP_MAXOFFSET ]);
    return $self;
}

lib/Net/IMP/HTTP/Example/FlipImg.pm  view on Meta::CPAN

	    $self->run_callback(
		[ IMP_REPLACE,1,$off,$self->{image} ], # unchanged image
		[ IMP_PASS,1,IMP_MAXOFFSET ]
	    );
	    $self->{ignore} = 1;
	}

	return;
    }

    # end of image reached, flip with Image::Magick
    debug("flip image size=%d",length($self->{image}));
    my $img = Image::Magick->new;
    debug("failed to flip img: $@") if ! eval {
	$img->BlobToImage($self->{image});
	$img->Flip;
	($self->{image}) = $img->ImageToBlob;
	debug("replace with ".length($self->{image})." bytes");
	1;
    };

    $self->run_callback(
	[ IMP_REPLACE,1,$self->offset(1),$self->{image} ],

t/01_load.t  view on Meta::CPAN

use Test::More tests => 9;

for my $pkg (
    'Net::IMP::HTTP',
    'Net::IMP::HTTP::Connection',
    'Net::IMP::Adaptor::STREAM2HTTPConn',
    'Net::IMP::HTTP::Request',
    [ 'Net::IMP::HTTP::Example::LogFormData', 'HTTP::Request' => 0 ],
    [ 'Net::IMP::HTTP::Example::SaveResponse', 'File::Path' => 2.07 ],
    'Net::IMP::HTTP::Example::AddXFooHeader',
    [ 'Net::IMP::HTTP::Example::FlipImg', 'Image::Magick' => 0 ],
    'Net::IMP::HTTP::Example::BlockContentType',
    #'Net::IMP::Adaptor::STREAM2HTTPReq',
) {
    if ( ! ref $pkg) {
	ok( eval "require $pkg",$pkg );
    } else {
	SKIP: {
	    ($pkg, my @dep) = @$pkg;
	    while (@dep) {
		my ($p,$v) = splice(@dep,0,2);



( run in 0.650 second using v1.01-cache-2.11-cpan-beeb90c9504 )