File Coverage

blib/lib/Weixin/Client/Request.pm
Criterion Covered Total %
statement 0 34 0.0
branch 0 10 0.0
condition 0 6 0.0
subroutine 0 8 0.0
pod 0 5 0.0
total 0 63 0.0


line stmt bran cond sub pod time code
1             package Weixin::Client::Request;
2             sub http_get{
3 0     0 0   my $self = shift;
4 0           my $ua = $self->{ua};
5 0           my $res = $ua->get(@_);
6 0           $self->{cookie_jar}->save;
7 0 0 0       return (defined $res and $res->is_success)?$res->content:undef;
8             }
9             sub asyn_http_get {
10 0     0 0   my $self = shift;
11 0           my $callback = pop;
12 0           my $ua = $self->{asyn_ua};
13             $ua->get(@_,sub{
14 0     0     my $response = shift;
15 0           $self->{cookie_jar}->save;
16 0 0         print $response->content(),"\n" if $self->{debug};
17 0           $callback->($response);
18 0           });
19             }
20             sub http_post{
21 0     0 0   my $self = shift;
22 0           my $ua = $self->{ua};
23 0           my $res = $ua->post(@_);
24 0           $self->{cookie_jar}->save;
25 0 0 0       return (defined $res and $res->is_success)?$res->content:undef;
26             }
27             sub asyn_http_post {
28 0     0 0   my $self = shift;
29 0           my $callback = pop;
30 0           my $ua = $self->{asyn_ua};
31             $ua->post(@_,sub{
32 0     0     my $response = shift;
33 0           $self->{cookie_jar}->save;
34 0 0         print $response->content(),"\n" if $self->{debug};
35 0           $callback->($response);
36 0           });
37             }
38              
39             sub search_cookie{
40 0     0 0   my($self,$cookie) = @_;
41 0           my $result = undef;
42             $self->{cookie_jar}->scan(sub{
43 0     0     my($version,$key,$val,$path,$domain,$port,$path_spec,$secure,$expires,$discard,$rest) =@_;
44 0 0         if($key eq $cookie){
45 0           $result = $val ;
46 0           return;
47             }
48 0           });
49 0           return $result;
50             }
51             1;