
05.02.2010, 23:01
|
|
Новичок
Регистрация: 28.11.2007
Сообщений: 12
С нами:
9711479
Репутация:
0
|
|
Спасибо, но все равно не прет почему-то...
Код:
#!/usr/bin/perl
use HTTP::Daemon;
use LWP::UserAgent;
use Compress::Zlib;
use CGI::Carp qw(fatalsToBrowser);
open(F, '<agents.txt') || die $!;
chomp(my @agents = <F>);
close F;
my $ua = LWP::UserAgent->new; # сам добавил, без этого не работал вообще код
$ua->agent($agents[rand @agents]);
my @ext = qw(x-gtar x-gzip x-tar zip image zip z gz tz taz tgz lzh arj arc tar cab wmz yfs wsz exe uu xxe bhx b64 hqx mim);
my $port = 8080;
$SIG{PIPE} = 'IGNORE';
my $server = HTTP::Daemon->new( LocalPort => $port ) or
die "Can't start server ($@)" unless defined $server;
while (my $conn = $server->accept) {
while (my $request = $conn->get_request) {
$conn->autoflush;
$request -> remove_header('Proxy-Connection');
$request -> remove_header('Keep-Alive');
$request -> header(Connection=>'close');
my $resp = $ua->simple_request($request);
my $c_cont = $resp->content;
if ( $resp->content_encoding || (grep { $_ =~ /$resp->content_type/g } @ext) || length($c_cont) < 3000 ) {
$conn->send_response($resp);
}
else {
$c_cont_zip = Compress::Zlib::memGzip($c_cont);
$resp->content($c_cont_zip);
$resp->content_encoding('gzip');
$conn->send_response($resp);
}
}
print STDERR "Close: ", $conn->reason, "\n";
$conn->close;
undef $conn;
}
|
|
|