--- AnyEvent-HTTP/HTTP.pm 2011/01/11 06:38:47 1.93 +++ AnyEvent-HTTP/HTTP.pm 2011/02/19 06:46:14 1.102 @@ -17,7 +17,7 @@ This module implements a simple, stateless and non-blocking HTTP client. It supports GET, POST and other request methods, cookies and more, -all on a very low level. It can follow redirects supports proxies and +all on a very low level. It can follow redirects, supports proxies, and automatically limits the number of connections to the values specified in the RFC. @@ -48,7 +48,7 @@ use base Exporter::; -our $VERSION = '2.01'; +our $VERSION = '2.04'; our @EXPORT = qw(http_get http_post http_head http_request); @@ -181,11 +181,14 @@ =item proxy => [$host, $port[, $scheme]] or undef -Use the given http proxy for all requests. If not specified, then the -default proxy (as specified by C<$ENV{http_proxy}>) is used. +Use the given http proxy for all requests, or no proxy if C is +used. C<$scheme> must be either missing or must be C for HTTP. +If not specified, then the default proxy is used (see +C). + =item body => $string The request body, usually empty. Will be sent as-is (future versions of @@ -531,7 +534,7 @@ \G\s* (?: expires \s*=\s* ([A-Z][a-z][a-z]+,\ [^,;]+) - | ([^=;,[:space:]]+) (?: \s*=\s* (?: "((?:[^\\"]+|\\.)*)" | ([^=;,[:space:]]*) ) )? + | ([^=;,[:space:]]+) (?: \s*=\s* (?: "((?:[^\\"]+|\\.)*)" | ([^;,[:space:]]*) ) )? ) }gcxsi ) { @@ -548,7 +551,7 @@ $value =~ s/\\(.)/$1/gs; } - push @kv, lc $name, $value; + push @kv, @kv ? lc $name : $name, $value; last unless /\G\s*;/gc; } @@ -711,11 +714,11 @@ return $cb->(undef, { @pseudo, Status => 599, Reason => "Too many redirections" }) if $recurse < 0; - my $proxy = $arg{proxy} || $PROXY; + my $proxy = exists $arg{proxy} ? $arg{proxy} : $PROXY; my $timeout = $arg{timeout} || $TIMEOUT; my ($uscheme, $uauthority, $upath, $query, undef) = # ignore fragment - $url =~ m|(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*)(?:(\?[^#]*))?(?:#(.*))?|; + $url =~ m|^([^:]+):(?://([^/?#]*))?([^?#]*)(?:(\?[^#]*))?(?:#(.*))?$|; $uscheme = lc $uscheme; @@ -1174,6 +1177,10 @@ To clear an already-set proxy, use C. +When AnyEvent::HTTP is laoded for the first time it will query the +default proxy from the operating system, currently by looking at +C<$ENV{http_proxy>}. + =item AnyEvent::HTTP::cookie_jar_expire $jar[, $session_end] Remove all cookies from the cookie jar that have been expired. If @@ -1334,8 +1341,8 @@ =head2 HTTP/1.1 FILE DOWNLOAD -Downloading files with HTTP cna be quite tricky, especially when something -goes wrong and you want tor esume. +Downloading files with HTTP can be quite tricky, especially when something +goes wrong and you want to resume. Here is a function that initiates and resumes a download. It uses the last modified time to check for file content changes, and works with many