ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent-HTTP/HTTP.pm
(Generate patch)

Comparing AnyEvent-HTTP/HTTP.pm (file contents):
Revision 1.101 by root, Wed Feb 16 16:34:34 2011 UTC vs.
Revision 1.102 by root, Sat Feb 19 06:46:14 2011 UTC

46use AnyEvent::Util (); 46use AnyEvent::Util ();
47use AnyEvent::Handle (); 47use AnyEvent::Handle ();
48 48
49use base Exporter::; 49use base Exporter::;
50 50
51our $VERSION = '2.03'; 51our $VERSION = '2.04';
52 52
53our @EXPORT = qw(http_get http_post http_head http_request); 53our @EXPORT = qw(http_get http_post http_head http_request);
54 54
55our $USERAGENT = "Mozilla/5.0 (compatible; U; AnyEvent-HTTP/$VERSION; +http://software.schmorp.de/pkg/AnyEvent)"; 55our $USERAGENT = "Mozilla/5.0 (compatible; U; AnyEvent-HTTP/$VERSION; +http://software.schmorp.de/pkg/AnyEvent)";
56our $MAX_RECURSE = 10; 56our $MAX_RECURSE = 10;
179 179
180Default timeout is 5 minutes. 180Default timeout is 5 minutes.
181 181
182=item proxy => [$host, $port[, $scheme]] or undef 182=item proxy => [$host, $port[, $scheme]] or undef
183 183
184Use the given http proxy for all requests. If not specified, then the 184Use the given http proxy for all requests, or no proxy if C<undef> is
185default proxy (as specified by C<$ENV{http_proxy}>) is used. 185used.
186 186
187C<$scheme> must be either missing or must be C<http> for HTTP. 187C<$scheme> must be either missing or must be C<http> for HTTP.
188
189If not specified, then the default proxy is used (see
190C<AnyEvent::HTTP::set_proxy>).
188 191
189=item body => $string 192=item body => $string
190 193
191The request body, usually empty. Will be sent as-is (future versions of 194The request body, usually empty. Will be sent as-is (future versions of
192this module might offer more options). 195this module might offer more options).
709 my $recurse = exists $arg{recurse} ? delete $arg{recurse} : $MAX_RECURSE; 712 my $recurse = exists $arg{recurse} ? delete $arg{recurse} : $MAX_RECURSE;
710 713
711 return $cb->(undef, { @pseudo, Status => 599, Reason => "Too many redirections" }) 714 return $cb->(undef, { @pseudo, Status => 599, Reason => "Too many redirections" })
712 if $recurse < 0; 715 if $recurse < 0;
713 716
714 my $proxy = $arg{proxy} || $PROXY; 717 my $proxy = exists $arg{proxy} ? $arg{proxy} : $PROXY;
715 my $timeout = $arg{timeout} || $TIMEOUT; 718 my $timeout = $arg{timeout} || $TIMEOUT;
716 719
717 my ($uscheme, $uauthority, $upath, $query, undef) = # ignore fragment 720 my ($uscheme, $uauthority, $upath, $query, undef) = # ignore fragment
718 $url =~ m|^([^:]+):(?://([^/?#]*))?([^?#]*)(?:(\?[^#]*))?(?:#(.*))?$|; 721 $url =~ m|^([^:]+):(?://([^/?#]*))?([^?#]*)(?:(\?[^#]*))?(?:#(.*))?$|;
719 722
1172Sets the default proxy server to use. The proxy-url must begin with a 1175Sets the default proxy server to use. The proxy-url must begin with a
1173string of the form C<http://host:port>, croaks otherwise. 1176string of the form C<http://host:port>, croaks otherwise.
1174 1177
1175To clear an already-set proxy, use C<undef>. 1178To clear an already-set proxy, use C<undef>.
1176 1179
1180When AnyEvent::HTTP is laoded for the first time it will query the
1181default proxy from the operating system, currently by looking at
1182C<$ENV{http_proxy>}.
1183
1177=item AnyEvent::HTTP::cookie_jar_expire $jar[, $session_end] 1184=item AnyEvent::HTTP::cookie_jar_expire $jar[, $session_end]
1178 1185
1179Remove all cookies from the cookie jar that have been expired. If 1186Remove all cookies from the cookie jar that have been expired. If
1180C<$session_end> is given and true, then additionally remove all session 1187C<$session_end> is given and true, then additionally remove all session
1181cookies. 1188cookies.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines