use strict; use LWP::UserAgent; package MyHttp; use vars qw(@ISA); require LWP::Protocol::http; @ISA = qw( LWP::Protocol::http ); sub _new_socket { my($self, $host, $port, $timeout) = @_; my $s; print "Creating New socket: $host, $port, $timeout\n"; $s = $self->SUPER::_new_socket($host,$port,$timeout); print "ok\n"; return $s; } package main; LWP::Protocol::implementor( http => 'MyHttp' ); my $ua = LWP::UserAgent->new(ssl_opts => { SSL_verify_mode => 'SSL_VERIFY_NONE'},); $ua->agent('Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/5.0)'); $ua->max_size(50000000); # 50MB at most $ua->timeout(45); my $request = HTTP::Request->new(GET => "http://www.google.ch/"); $request->protocol('HTTP/1.0'); # we don't want chunked replies $request->header('Accept' => '*/*'); $request->header('Accept-Encoding' => ''); # we don't want packed results $request->header('Connection' => 'Close'); $request->header('Cache-Control' => 'no-cache'); my $resp = $ua->request($request); if ($resp->is_success) { my $data = $resp->content; print "$data\n"; } #### $ perl porttest.pl Creating New socket: www.google.ch, 80, 45 $