| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Copyrights 2011 by Mark Overmeer. |
|
2
|
|
|
|
|
|
|
# For other contributors see ChangeLog. |
|
3
|
|
|
|
|
|
|
# See the manual pages for details on the licensing terms. |
|
4
|
|
|
|
|
|
|
# Pod stripped from pm file by OODoc 1.07. |
|
5
|
1
|
|
|
1
|
|
1668
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
34
|
|
|
6
|
1
|
|
|
1
|
|
4
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
36
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package IOMux::HTTP::Client; |
|
9
|
1
|
|
|
1
|
|
5
|
use vars '$VERSION'; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
60
|
|
|
10
|
|
|
|
|
|
|
$VERSION = '0.11'; |
|
11
|
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
5
|
use base 'IOMux::HTTP'; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
102
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
6
|
use Log::Report 'iomux-http'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
11
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
346
|
use HTTP::Request (); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
19
|
|
|
17
|
1
|
|
|
1
|
|
5
|
use HTTP::Response (); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
6235
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub init($) |
|
21
|
0
|
|
|
0
|
0
|
|
{ my ($self, $args) = @_; |
|
22
|
0
|
|
|
|
|
|
$self->SUPER::init($args); |
|
23
|
0
|
|
|
|
|
|
$self->{IMHC_sent} = []; |
|
24
|
0
|
|
|
|
|
|
$self; |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
#-------------- |
|
28
|
|
|
|
|
|
|
|
|
29
|
0
|
|
|
0
|
1
|
|
sub msgsSent() {shift->{IMHC_sent}} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
#-------------- |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub sendRequest($$$) |
|
34
|
0
|
|
|
0
|
1
|
|
{ my ($self, $req, $cb, $session) = @_; |
|
35
|
0
|
|
|
|
|
|
$req->header(Accept_Transfer_Encoding => 'chunked, 8bit'); |
|
36
|
0
|
|
|
|
|
|
$req->protocol('HTTP/1.1'); |
|
37
|
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
push @{$self->{IMHC_sent}}, [$req, $cb, $session]; |
|
|
0
|
|
|
|
|
|
|
|
39
|
0
|
|
|
0
|
|
|
$self->sendMessage($req, sub { |
|
40
|
|
|
|
|
|
|
# message sent completed |
|
41
|
0
|
|
|
|
|
|
}); |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub headerArrived($) |
|
45
|
0
|
|
|
0
|
0
|
|
{ my $self = shift; |
|
46
|
0
|
|
|
|
|
|
HTTP::Response->parse(shift); |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub messageArrived($) |
|
50
|
0
|
|
|
0
|
0
|
|
{ my ($self, $resp) = @_; |
|
51
|
0
|
|
|
|
|
|
my $waiting = shift @{$self->{IMHC_sent}}; |
|
|
0
|
|
|
|
|
|
|
|
52
|
0
|
0
|
|
|
|
|
unless($waiting) |
|
53
|
0
|
|
|
|
|
|
{ alert "message arrived, but there was no request"; |
|
54
|
0
|
|
|
|
|
|
return; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
0
|
|
|
|
|
|
my ($req, $cb, $session) = @$waiting; |
|
57
|
0
|
|
|
|
|
|
$cb->($self, $req, $resp->code, $resp, $session); |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |