… | |
… | |
48 | use AnyEvent::Socket (); |
48 | use AnyEvent::Socket (); |
49 | use AnyEvent::Handle (); |
49 | use AnyEvent::Handle (); |
50 | |
50 | |
51 | use base Exporter::; |
51 | use base Exporter::; |
52 | |
52 | |
53 | our $VERSION = '1.03'; |
53 | our $VERSION = '1.05'; |
54 | |
54 | |
55 | our @EXPORT = qw(http_get http_post http_head http_request); |
55 | our @EXPORT = qw(http_get http_post http_head http_request); |
56 | |
56 | |
57 | our $USERAGENT = "Mozilla/5.0 (compatible; AnyEvent::HTTP/$VERSION; +http://software.schmorp.de/pkg/AnyEvent)"; |
57 | our $USERAGENT = "Mozilla/5.0 (compatible; AnyEvent::HTTP/$VERSION; +http://software.schmorp.de/pkg/AnyEvent)"; |
58 | our $MAX_RECURSE = 10; |
58 | our $MAX_RECURSE = 10; |
… | |
… | |
80 | Executes an HTTP-HEAD request. See the http_request function for details on |
80 | Executes an HTTP-HEAD request. See the http_request function for details on |
81 | additional parameters. |
81 | additional parameters. |
82 | |
82 | |
83 | =item http_post $url, $body, key => value..., $cb->($data, $headers) |
83 | =item http_post $url, $body, key => value..., $cb->($data, $headers) |
84 | |
84 | |
85 | Executes an HTTP-POST request with a request body of C<$bod>. See the |
85 | Executes an HTTP-POST request with a request body of C<$body>. See the |
86 | http_request function for details on additional parameters. |
86 | http_request function for details on additional parameters. |
87 | |
87 | |
88 | =item http_request $method => $url, key => value..., $cb->($data, $headers) |
88 | =item http_request $method => $url, key => value..., $cb->($data, $headers) |
89 | |
89 | |
90 | Executes a HTTP request of type C<$method> (e.g. C<GET>, C<POST>). The URL |
90 | Executes a HTTP request of type C<$method> (e.g. C<GET>, C<POST>). The URL |
… | |
… | |
398 | my %kv = (value => $value, map { split /=/, $_, 2 } @arg); |
398 | my %kv = (value => $value, map { split /=/, $_, 2 } @arg); |
399 | |
399 | |
400 | my $cdom = (delete $kv{domain}) || $uhost; |
400 | my $cdom = (delete $kv{domain}) || $uhost; |
401 | my $cpath = (delete $kv{path}) || "/"; |
401 | my $cpath = (delete $kv{path}) || "/"; |
402 | |
402 | |
403 | $cdom =~ s/^.?/./; # make sure it starts with a "." |
403 | $cdom =~ s/^\.?/./; # make sure it starts with a "." |
404 | |
404 | |
405 | next if $cdom =~ /\.$/; |
405 | next if $cdom =~ /\.$/; |
406 | |
406 | |
407 | # this is not rfc-like and not netscape-like. go figure. |
407 | # this is not rfc-like and not netscape-like. go figure. |
408 | my $ndots = $cdom =~ y/.//; |
408 | my $ndots = $cdom =~ y/.//; |