
05.02.2010, 03:47
|
|
Banned
Регистрация: 24.08.2006
Сообщений: 483
Провел на форуме: 3895065
Репутация:
1112
|
|
по моему код нужно править начиная здесь
PHP код:
#!/usr/bin/perl
use HTTP::Daemon;
use LWP::UserAgent;
use Compress::Zlib;
use CGI::Carp qw(fatalsToBrowser);
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) {
my $ua = LWP::UserAgent->new;
my $str = do {my $fh = open "<filename.txt"; local $/ = undef; <$fh>};
chomp $str;
$ua->default_header('My header' => $str);}
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;
}
но это не точно
|
|
|