… | |
… | |
121 | Whether to recurse requests or not, e.g. on redirects, authentication |
121 | Whether to recurse requests or not, e.g. on redirects, authentication |
122 | retries and so on, and how often to do so. |
122 | retries and so on, and how often to do so. |
123 | |
123 | |
124 | =item headers => hashref |
124 | =item headers => hashref |
125 | |
125 | |
126 | The request headers to use. |
126 | The request headers to use. Currently, C<http_request> may provide its |
|
|
127 | own C<Host:>, C<Content-Length:>, C<Connection:> and C<Cookie:> headers |
|
|
128 | and will provide defaults for C<User-Agent:> and C<Referer:>. |
127 | |
129 | |
128 | =item timeout => $seconds |
130 | =item timeout => $seconds |
129 | |
131 | |
130 | The time-out to use for various stages - each connect attempt will reset |
132 | The time-out to use for various stages - each connect attempt will reset |
131 | the timeout, as will read or write activity. Default timeout is 5 minutes. |
133 | the timeout, as will read or write activity. Default timeout is 5 minutes. |
… | |
… | |
181 | } |
183 | } |
182 | ; |
184 | ; |
183 | |
185 | |
184 | =cut |
186 | =cut |
185 | |
187 | |
|
|
188 | sub _slot_schedule; |
186 | sub _slot_schedule($) { |
189 | sub _slot_schedule($) { |
187 | my $host = shift; |
190 | my $host = shift; |
188 | |
191 | |
189 | while ($CO_SLOT{$host}[0] < $MAX_PER_HOST) { |
192 | while ($CO_SLOT{$host}[0] < $MAX_PER_HOST) { |
190 | if (my $cb = shift @{ $CO_SLOT{$host}[1] }) { |
193 | if (my $cb = shift @{ $CO_SLOT{$host}[1] }) { |
191 | # somebody wnats that slot |
194 | # somebody wants that slot |
192 | ++$CO_SLOT{$host}[0]; |
195 | ++$CO_SLOT{$host}[0]; |
193 | |
196 | |
194 | $cb->(AnyEvent::Util::guard { |
197 | $cb->(AnyEvent::Util::guard { |
195 | --$CO_SLOT{$host}[0]; |
198 | --$CO_SLOT{$host}[0]; |
196 | _slot_schedule $host; |
199 | _slot_schedule $host; |
197 | }); |
200 | }); |
198 | } else { |
201 | } else { |
199 | # nobody wants the slot, maybe we can forget about it |
202 | # nobody wants the slot, maybe we can forget about it |
200 | delete $CO_SLOT{$host} unless $CO_SLOT{$host}[0]; |
203 | delete $CO_SLOT{$host} unless $CO_SLOT{$host}[0]; |
201 | warn "$host deleted" unless $CO_SLOT{$host}[0];#d# |
|
|
202 | last; |
204 | last; |
203 | } |
205 | } |
204 | } |
206 | } |
205 | } |
207 | } |
206 | |
208 | |
… | |
… | |
252 | |
254 | |
253 | $uhost =~ s/^\[(.*)\]$/$1/; |
255 | $uhost =~ s/^\[(.*)\]$/$1/; |
254 | $upath .= "?$query" if length $query; |
256 | $upath .= "?$query" if length $query; |
255 | |
257 | |
256 | $upath =~ s%^/?%/%; |
258 | $upath =~ s%^/?%/%; |
|
|
259 | |
|
|
260 | $hdr{referer} ||= "$scheme://$authority$upath"; |
257 | |
261 | |
258 | # cookie processing |
262 | # cookie processing |
259 | if (my $jar = $arg{cookie_jar}) { |
263 | if (my $jar = $arg{cookie_jar}) { |
260 | %$jar = () if $jar->{version} < 1; |
264 | %$jar = () if $jar->{version} < 1; |
261 | |
265 | |