ndle;
use AnyEvent::Socket;
use AnyEvent::Util;
use LWP::MediaTypes qw(guess_media_type);
use JSON::XS;
#use IO::Uncompress::Gunzip qw(gunzip $GunzipError) ;
#use IO::Compress::Gzip qw(gzip $Gzi
charset=utf8';
if (ref($data) eq 'HASH') { ### $data is hash pointer, encode it to json data
$data=encode_json($data);
}
$hdr->{'Content-Length'} = length $data;
while (my ($h, $v) = each
r,$key,$data)=@_;
unless ($n->{http_sec}->($r,$key)) {
return 0;
}
eval{$data=decode_json($data)};
if ($@) {
$n->{send_resp}->($r,$key, {url=>'/op',result=>'error',reason=>"Post data