… | |
… | |
126 | The request body, usually empty. Will be-sent as-is (future versions of |
126 | The request body, usually empty. Will be-sent as-is (future versions of |
127 | this module might offer more options). |
127 | this module might offer more options). |
128 | |
128 | |
129 | =back |
129 | =back |
130 | |
130 | |
131 | =back |
131 | Example: make a simple HTTP GET request for http://www.nethype.de/ |
|
|
132 | |
|
|
133 | http_request GET => "http://www.nethype.de/", sub { |
|
|
134 | my ($body, $hdr) = @_; |
|
|
135 | print "$body\n"; |
|
|
136 | }; |
|
|
137 | |
|
|
138 | Example: make a HTTP HEAD request on https://www.google.com/, use a |
|
|
139 | timeout of 30 seconds. |
|
|
140 | |
|
|
141 | http_request |
|
|
142 | GET => "https://www.google.com", |
|
|
143 | timeout => 30, |
|
|
144 | sub { |
|
|
145 | my ($body, $hdr) = @_; |
|
|
146 | use Data::Dumper; |
|
|
147 | print Dumper $hdr; |
|
|
148 | } |
|
|
149 | ; |
132 | |
150 | |
133 | =cut |
151 | =cut |
134 | |
152 | |
135 | sub http_request($$$;@) { |
153 | sub http_request($$$;@) { |
136 | my $cb = pop; |
154 | my $cb = pop; |
… | |
… | |
317 | sub http_post($$$;@) { |
335 | sub http_post($$$;@) { |
318 | unshift @_, "POST", "body"; |
336 | unshift @_, "POST", "body"; |
319 | &http_request |
337 | &http_request |
320 | } |
338 | } |
321 | |
339 | |
|
|
340 | =back |
|
|
341 | |
322 | =head2 GLOBAL FUNCTIONS AND VARIABLES |
342 | =head2 GLOBAL FUNCTIONS AND VARIABLES |
323 | |
343 | |
324 | =over 4 |
344 | =over 4 |
325 | |
345 | |
326 | =item AnyEvent::HTTP::set_proxy "proxy-url" |
346 | =item AnyEvent::HTTP::set_proxy "proxy-url" |