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.14 by root, Thu Jun 5 17:29:01 2008 UTC vs.
Revision 1.17 by root, Fri Jun 6 13:02:38 2008 UTC

3AnyEvent::HTTP - simple but non-blocking HTTP/HTTPS client 3AnyEvent::HTTP - simple but non-blocking HTTP/HTTPS client
4 4
5=head1 SYNOPSIS 5=head1 SYNOPSIS
6 6
7 use AnyEvent::HTTP; 7 use AnyEvent::HTTP;
8
9 http_get "http://www.nethype.de/", sub { print $_[1] };
10
11 # ... do something else here
8 12
9=head1 DESCRIPTION 13=head1 DESCRIPTION
10 14
11This module is an L<AnyEvent> user, you need to make sure that you use and 15This module is an L<AnyEvent> user, you need to make sure that you use and
12run a supported event loop. 16run a supported event loop.
44use AnyEvent::Socket (); 48use AnyEvent::Socket ();
45use AnyEvent::Handle (); 49use AnyEvent::Handle ();
46 50
47use base Exporter::; 51use base Exporter::;
48 52
49our $VERSION = '1.0'; 53our $VERSION = '1.01';
50 54
51our @EXPORT = qw(http_get http_request); 55our @EXPORT = qw(http_get http_post http_head http_request);
52 56
53our $USERAGENT = "Mozilla/5.0 (compatible; AnyEvent::HTTP/$VERSION; +http://software.schmorp.de/pkg/AnyEvent)"; 57our $USERAGENT = "Mozilla/5.0 (compatible; AnyEvent::HTTP/$VERSION; +http://software.schmorp.de/pkg/AnyEvent)";
54our $MAX_RECURSE = 10; 58our $MAX_RECURSE = 10;
55our $MAX_PERSISTENT = 8; 59our $MAX_PERSISTENT = 8;
56our $PERSISTENT_TIMEOUT = 2; 60our $PERSISTENT_TIMEOUT = 2;
214 push @{ $CO_SLOT{$_[0]}[1] }, $_[1]; 218 push @{ $CO_SLOT{$_[0]}[1] }, $_[1];
215 219
216 _slot_schedule $_[0]; 220 _slot_schedule $_[0];
217} 221}
218 222
219sub http_request($$$;@) { 223sub http_request($$@) {
220 my $cb = pop; 224 my $cb = pop;
221 my ($method, $url, %arg) = @_; 225 my ($method, $url, %arg) = @_;
222 226
223 my %hdr; 227 my %hdr;
224 228
447 }; 451 };
448 452
449 defined wantarray && AnyEvent::Util::guard { %state = () } 453 defined wantarray && AnyEvent::Util::guard { %state = () }
450} 454}
451 455
452sub http_get($$;@) { 456sub http_get($@) {
453 unshift @_, "GET"; 457 unshift @_, "GET";
454 &http_request 458 &http_request
455} 459}
456 460
457sub http_head($$;@) { 461sub http_head($@) {
458 unshift @_, "HEAD"; 462 unshift @_, "HEAD";
459 &http_request 463 &http_request
460} 464}
461 465
462sub http_post($$$;@) { 466sub http_post($$@) {
463 unshift @_, "POST", "body"; 467 unshift @_, "POST", "body";
464 &http_request 468 &http_request
465} 469}
466 470
467=back 471=back

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines