… | |
… | |
169 | C<Host:>, C<Content-Length:>, C<Connection:> and C<Cookie:> headers and |
169 | C<Host:>, C<Content-Length:>, C<Connection:> and C<Cookie:> headers and |
170 | will provide defaults at least for C<TE:>, C<Referer:> and C<User-Agent:> |
170 | will provide defaults at least for C<TE:>, C<Referer:> and C<User-Agent:> |
171 | (this can be suppressed by using C<undef> for these headers in which case |
171 | (this can be suppressed by using C<undef> for these headers in which case |
172 | they won't be sent at all). |
172 | they won't be sent at all). |
173 | |
173 | |
|
|
174 | You really should provide your own C<User-Agent:> header value that is |
|
|
175 | appropriate for your program - I wouldn't be surprised if the default |
|
|
176 | AnyEvent string gets blocked by webservers sooner or later. |
|
|
177 | |
174 | =item timeout => $seconds |
178 | =item timeout => $seconds |
175 | |
179 | |
176 | The time-out to use for various stages - each connect attempt will reset |
180 | The time-out to use for various stages - each connect attempt will reset |
177 | the timeout, as will read or write activity, i.e. this is not an overall |
181 | the timeout, as will read or write activity, i.e. this is not an overall |
178 | timeout. |
182 | timeout. |
… | |
… | |
329 | Example: do a HTTP HEAD request on https://www.google.com/, use a |
333 | Example: do a HTTP HEAD request on https://www.google.com/, use a |
330 | timeout of 30 seconds. |
334 | timeout of 30 seconds. |
331 | |
335 | |
332 | http_request |
336 | http_request |
333 | GET => "https://www.google.com", |
337 | GET => "https://www.google.com", |
|
|
338 | headers => { "user-agent" => "MySearchClient 1.0" }, |
334 | timeout => 30, |
339 | timeout => 30, |
335 | sub { |
340 | sub { |
336 | my ($body, $hdr) = @_; |
341 | my ($body, $hdr) = @_; |
337 | use Data::Dumper; |
342 | use Data::Dumper; |
338 | print Dumper $hdr; |
343 | print Dumper $hdr; |