… | |
… | |
198 | C<AnyEvent::HTTP::set_proxy>). |
198 | C<AnyEvent::HTTP::set_proxy>). |
199 | |
199 | |
200 | Currently, if your proxy requires authorization, you have to specify an |
200 | Currently, if your proxy requires authorization, you have to specify an |
201 | appropriate "Proxy-Authorization" header in every request. |
201 | appropriate "Proxy-Authorization" header in every request. |
202 | |
202 | |
|
|
203 | Note that this module will prefer an existing persistent connection, |
|
|
204 | even if that connection was made using another proxy. If you need to |
|
|
205 | ensure that a new connection is made in this case, you can either force |
|
|
206 | C<persistent> to false or e.g. use the proxy address in your C<sessionid>. |
|
|
207 | |
203 | =item body => $string |
208 | =item body => $string |
204 | |
209 | |
205 | The request body, usually empty. Will be sent as-is (future versions of |
210 | The request body, usually empty. Will be sent as-is (future versions of |
206 | this module might offer more options). |
211 | this module might offer more options). |
207 | |
212 | |
… | |
… | |
239 | The default for this option is C<low>, which could be interpreted as "give |
244 | The default for this option is C<low>, which could be interpreted as "give |
240 | me the page, no matter what". |
245 | me the page, no matter what". |
241 | |
246 | |
242 | See also the C<sessionid> parameter. |
247 | See also the C<sessionid> parameter. |
243 | |
248 | |
244 | =item session => $string |
249 | =item sessionid => $string |
245 | |
250 | |
246 | The module might reuse connections to the same host internally. Sometimes |
251 | The module might reuse connections to the same host internally (regardless |
247 | (e.g. when using TLS), you do not want to reuse connections from other |
252 | of other settings, such as C<tcp_connect> or C<proxy>). Sometimes (e.g. |
|
|
253 | when using TLS or a specfic proxy), you do not want to reuse connections |
248 | sessions. This can be achieved by setting this parameter to some unique |
254 | from other sessions. This can be achieved by setting this parameter to |
249 | ID (such as the address of an object storing your state data, or the TLS |
255 | some unique ID (such as the address of an object storing your state data |
250 | context) - only connections using the same unique ID will be reused. |
256 | or the TLS context, or the proxy IP) - only connections using the same |
|
|
257 | unique ID will be reused. |
251 | |
258 | |
252 | =item on_prepare => $callback->($fh) |
259 | =item on_prepare => $callback->($fh) |
253 | |
260 | |
254 | In rare cases you need to "tune" the socket before it is used to |
261 | In rare cases you need to "tune" the socket before it is used to |
255 | connect (for example, to bind it on a given IP address). This parameter |
262 | connect (for example, to bind it on a given IP address). This parameter |
… | |
… | |
263 | In even rarer cases you want total control over how AnyEvent::HTTP |
270 | In even rarer cases you want total control over how AnyEvent::HTTP |
264 | establishes connections. Normally it uses L<AnyEvent::Socket::tcp_connect> |
271 | establishes connections. Normally it uses L<AnyEvent::Socket::tcp_connect> |
265 | to do this, but you can provide your own C<tcp_connect> function - |
272 | 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 |
273 | obviously, it has to follow the same calling conventions, except that it |
267 | may always return a connection guard object. |
274 | may always return a connection guard object. |
|
|
275 | |
|
|
276 | The connections made by this hook will be treated as equivalent to |
|
|
277 | connections made the built-in way, specifically, they will be put into |
|
|
278 | and taken from the persistent connection cache. If your C<$tcp_connect> |
|
|
279 | function is incompatible with this kind of re-use, consider switching off |
|
|
280 | C<persistent> connections and/or providing a C<sessionid> identifier. |
268 | |
281 | |
269 | There are probably lots of weird uses for this function, starting from |
282 | 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 |
283 | tracing the hosts C<http_request> actually tries to connect, to (inexact |
271 | but fast) host => IP address caching or even socks protocol support. |
284 | but fast) host => IP address caching or even socks protocol support. |
272 | |
285 | |
… | |
… | |
342 | =item persistent => $boolean |
355 | =item persistent => $boolean |
343 | |
356 | |
344 | Try to create/reuse a persistent connection. When this flag is set |
357 | Try to create/reuse a persistent connection. When this flag is set |
345 | (default: true for idempotent requests, false for all others), then |
358 | (default: true for idempotent requests, false for all others), then |
346 | C<http_request> tries to re-use an existing (previously-created) |
359 | 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 |
360 | persistent connection to same host (i.e. identical URL scheme, hostname, |
348 | one. |
361 | port and sessionid) and, failing that, tries to create a new one. |
349 | |
362 | |
350 | Requests failing in certain ways will be automatically retried once, which |
363 | 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 |
364 | 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 |
365 | 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 |
366 | made it impossible to distinguish between a fatal error and a normal |
354 | connection timeout, so you never know whether there was a problem with |
367 | connection timeout, so you never know whether there was a problem with |
355 | your request or not. |
368 | your request or not. |
356 | |
369 | |
357 | When reusing an existent connection, many parameters (such as TLS context) |
370 | When reusing an existent connection, many parameters (such as TLS context) |
358 | will be ignored. See the C<session> parameter for a workaround. |
371 | will be ignored. See the C<sessionid> parameter for a workaround. |
359 | |
372 | |
360 | =item keepalive => $boolean |
373 | =item keepalive => $boolean |
361 | |
374 | |
362 | Only used when C<persistent> is also true. This parameter decides whether |
375 | Only used when C<persistent> is also true. This parameter decides whether |
363 | C<http_request> tries to handshake a HTTP/1.0-style keep-alive connection |
376 | C<http_request> tries to handshake a HTTP/1.0-style keep-alive connection |
… | |
… | |
1309 | |
1322 | |
1310 | Here is an example of a cookie jar with a single cookie, so you have a |
1323 | Here is an example of a cookie jar with a single cookie, so you have a |
1311 | chance of understanding the above paragraph: |
1324 | chance of understanding the above paragraph: |
1312 | |
1325 | |
1313 | { |
1326 | { |
1314 | version => 1, |
1327 | version => 2, |
1315 | "10.0.0.1" => { |
1328 | "10.0.0.1" => { |
1316 | "/" => { |
1329 | "/" => { |
1317 | "mythweb_id" => { |
1330 | "mythweb_id" => { |
1318 | _expires => 1293917923, |
1331 | _expires => 1293917923, |
1319 | value => "ooRung9dThee3ooyXooM1Ohm", |
1332 | value => "ooRung9dThee3ooyXooM1Ohm", |