Revision 35 (by dpavlin, 2008/09/29 13:43:37) fix google maps extraction
package Net::Analysis::Listener::Maps;

use strict;
use warnings;
use base qw(Net::Analysis::Listener::Base);
use File::Slurp;

my $i = 0;

sub http_transaction {
    my ($self, $args) = @_;
    my ($req)       = $args->{req};         # isa HTTP::Request
    my ($resp)      = $args->{resp};         # isa HTTP::Response
    my ($req_mono)  = $args->{req_mono};    # isa Net::Analysis::TCPMonologue
    my ($resp_mono) = $args->{resp_mono};   # isa Net::Analysis::TCPMonologue

	my $file;

	if ( $req->uri() =~ m!/GElin/MapSrv\.aspx\?lwM=(\d+)&twM=(\d+)&zf=(\d+)! ) {
		# Mireo
		$file = "$3/$1-$2.gif";
	} elsif ( $req->uri() =~ m!/mt\?.*x=(\d+).*?&y=(\d+).*?&z=(\d+)! ) {
		# Google maps
		$file = "$3/$1-$2.png";
	} elsif ( $req->uri() =~ m!/aerial.maps.yimg.com/img.*&x=(\d+)&y=(\d+)&z=(\d+)&v=1\.7! ) {
		# Yahoo maps
		$file = "$3/$1-$2.jpg";
	} elsif ( $req->uri() =~ m!/GElin/mireo.NET.MapSearchWeb! ) {
		$file = "foo$i";
		$i++;
	}

	if ( $file ) {
		mkdir "dump" unless -e "dump";
		mkdir "dump/$3" unless -e "dump/$3";
		write_file( "dump/$file", $resp->content );
		print "$1x$2 zoom: $3 -> $file ", -s "dump/$file", " bytes\n";
	} else {
		print ">> ",$req->uri, "\n";
	}


}

1;

=head1 NAME

Net::Analysis::Listener::Maps - looking at HTTP transactions

 $ perl -MNet::Analysis -e main HTTP Maps maps_dump.tcp