test

sub handle_client_data{
my ($fh,$key)=@_;
$self->{client}->{$key}=AnyEvent::Handle->new (
fh => $fh,
timeout => 100,
   key=> $key,
on_eof => sub {
if ($client_conn->{$key}->{http}->{gzip_flag}) {
my $host=$server_conn->{$key}->{http}->{action}->{header}->{Host};
my $url=$server_conn->{$key}->{http}->{action}->{url};
$cache->{$host}->{$url}=$client_conn->{$key}->{http}->{all_data};
print "$key\n";
on_server_send_data($key,\$cache->{$host}->{$url});
c_local();
}
on_disconnect('client',$key);
},
on_error => sub {
on_connect_err('client',$key);
},
on_read => sub {
my $data=$_[0]->rbuf;
$_[0]->{rbuf}='';
#on_server_send_data($key,\$data);
#return 1;
if (process_client_data($key,\$data) == 1) {
my $host=$server_conn->{$key}->{http}->{action}->{header}->{Host};
my $url=$server_conn->{$key}->{http}->{action}->{url};
$cache->{$host}->{$url}=$client_conn->{$key}->{http}->{all_data};
on_server_send_data($key,\$cache->{$host}->{$url});
c_local();
}elsif(process_client_data($key,\$data) == -1){
on_disconnect('client',$key);
}else{
return 1;
}
},
on_drain => sub {
#undef $self->{handle};
}
);
return 1;
}

Comments