… | |
… | |
264 | establishes connections. Normally it uses L<AnyEvent::Socket::tcp_connect> |
264 | establishes connections. Normally it uses L<AnyEvent::Socket::tcp_connect> |
265 | to do this, but you can provide your own C<tcp_connect> function - |
265 | to do this, but you can provide your own C<tcp_connect> function - |
266 | obviously, it has to follow the same calling conventions, except that it |
266 | obviously, it has to follow the same calling conventions, except that it |
267 | may always return a connection guard object. |
267 | may always return a connection guard object. |
268 | |
268 | |
|
|
269 | The connections made by this hook will be treated as equivalent to |
|
|
270 | connecitons made the built-in way, specifically, they will be put into |
|
|
271 | and taken from the persistent conneciton cache. If your C<$tcp_connect> |
|
|
272 | function is incompatible with this kind of re-use, consider switching off |
|
|
273 | C<persistent> connections and/or providing a C<session> identifier. |
|
|
274 | |
269 | There are probably lots of weird uses for this function, starting from |
275 | There are probably lots of weird uses for this function, starting from |
270 | tracing the hosts C<http_request> actually tries to connect, to (inexact |
276 | tracing the hosts C<http_request> actually tries to connect, to (inexact |
271 | but fast) host => IP address caching or even socks protocol support. |
277 | but fast) host => IP address caching or even socks protocol support. |
272 | |
278 | |
273 | =item on_header => $callback->($headers) |
279 | =item on_header => $callback->($headers) |
… | |
… | |
342 | =item persistent => $boolean |
348 | =item persistent => $boolean |
343 | |
349 | |
344 | Try to create/reuse a persistent connection. When this flag is set |
350 | Try to create/reuse a persistent connection. When this flag is set |
345 | (default: true for idempotent requests, false for all others), then |
351 | (default: true for idempotent requests, false for all others), then |
346 | C<http_request> tries to re-use an existing (previously-created) |
352 | C<http_request> tries to re-use an existing (previously-created) |
347 | persistent connection to the host and, failing that, tries to create a new |
353 | persistent connection to same host (i.e. identical URL scheme, hostname, |
348 | one. |
354 | port and session) and, failing that, tries to create a new one. |
349 | |
355 | |
350 | Requests failing in certain ways will be automatically retried once, which |
356 | Requests failing in certain ways will be automatically retried once, which |
351 | is dangerous for non-idempotent requests, which is why it defaults to off |
357 | is dangerous for non-idempotent requests, which is why it defaults to off |
352 | for them. The reason for this is because the bozos who designed HTTP/1.1 |
358 | for them. The reason for this is because the bozos who designed HTTP/1.1 |
353 | made it impossible to distinguish between a fatal error and a normal |
359 | made it impossible to distinguish between a fatal error and a normal |
… | |
… | |
1294 | function from time to time. |
1300 | function from time to time. |
1295 | |
1301 | |
1296 | A cookie jar is initially an empty hash-reference that is managed by this |
1302 | A cookie jar is initially an empty hash-reference that is managed by this |
1297 | module. Its format is subject to change, but currently it is as follows: |
1303 | module. Its format is subject to change, but currently it is as follows: |
1298 | |
1304 | |
1299 | The key C<version> has to contain C<1>, otherwise the hash gets |
1305 | The key C<version> has to contain C<2>, otherwise the hash gets |
1300 | emptied. All other keys are hostnames or IP addresses pointing to |
1306 | cleared. All other keys are hostnames or IP addresses pointing to |
1301 | hash-references. The key for these inner hash references is the |
1307 | hash-references. The key for these inner hash references is the |
1302 | server path for which this cookie is meant, and the values are again |
1308 | server path for which this cookie is meant, and the values are again |
1303 | hash-references. Each key of those hash-references is a cookie name, and |
1309 | hash-references. Each key of those hash-references is a cookie name, and |
1304 | the value, you guessed it, is another hash-reference, this time with the |
1310 | the value, you guessed it, is another hash-reference, this time with the |
1305 | key-value pairs from the cookie, except for C<expires> and C<max-age>, |
1311 | key-value pairs from the cookie, except for C<expires> and C<max-age>, |
… | |
… | |
1309 | |
1315 | |
1310 | Here is an example of a cookie jar with a single cookie, so you have a |
1316 | Here is an example of a cookie jar with a single cookie, so you have a |
1311 | chance of understanding the above paragraph: |
1317 | chance of understanding the above paragraph: |
1312 | |
1318 | |
1313 | { |
1319 | { |
1314 | version => 1, |
1320 | version => 2, |
1315 | "10.0.0.1" => { |
1321 | "10.0.0.1" => { |
1316 | "/" => { |
1322 | "/" => { |
1317 | "mythweb_id" => { |
1323 | "mythweb_id" => { |
1318 | _expires => 1293917923, |
1324 | _expires => 1293917923, |
1319 | value => "ooRung9dThee3ooyXooM1Ohm", |
1325 | value => "ooRung9dThee3ooyXooM1Ohm", |