afbrudt en forbindelse
Hejdenne fil sender informationer til en 3. partie
som skal vi afbrudt
er der nogen ekspert som kan hjælpe?
Tak
-----------------------------------------
sub get {
my $path = shift;
$path =~ s|http://([^/:]+)(:(\d+))?||;
$path or $path = "/";
my $host = $1;
my $port = $3 || 80;
require IO::Socket;
local($^W) = 0;
my $sock = IO::Socket::INET->new(PeerAddr => $host,
PeerPort => $port,
Proto => 'tcp',
Timeout => 5) || return;
$sock->autoflush;
my $netloc = $host;
$netloc .= ":$port" if $port != 80;
print $sock join("\015\012" =>
"GET $path HTTP/1.0",
"Host: $netloc",
"User-Agent: MY SCRIPT",
"", "");
my $buf = "";
my $n;
1 while $n = sysread($sock, $buf, 8*1024, length($buf));
return undef unless defined($n);
if ($buf =~ m,^HTTP/\d+\.\d+\s+(\d+)[^\012]*\012,) {
my $code = $1;
#print "CODE=$code\n$buf\n";
if ($code =~ /^30[1237]/ && $buf =~ /\012Location:\s*(\S+)/) {
# redirect
my $url = $1;
return undef if $loop_check{$url}++;
return get($url);
}
return undef unless $code =~ /^2/;
$buf =~ s/.+?\015?\012\015?\012//s; # zap header
}
return $buf;
}
1;
-----------------------------------------