ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/t/handle/03_http_req.t
(Generate patch)

Comparing AnyEvent/t/handle/03_http_req.t (file contents):
Revision 1.6 by elmex, Thu May 15 14:12:24 2008 UTC vs.
Revision 1.9 by root, Fri May 23 17:50:15 2008 UTC

1#!/opt/perl/bin/perl 1#!/opt/perl/bin/perl
2
2use strict; 3use strict;
4
3use AnyEvent::Impl::Perl; 5use AnyEvent::Impl::Perl;
4use AnyEvent; 6use AnyEvent;
5use AnyEvent::Socket; 7use AnyEvent::Socket;
8use AnyEvent::Handle;
6 9
7unless ($ENV{PERL_ANYEVENT_NET_TESTS}) { 10unless ($ENV{PERL_ANYEVENT_NET_TESTS}) {
8 print "1..0 # Skip PERL_ANYEVENT_NET_TESTS environment variable not set\n"; 11 print "1..0 # Skip PERL_ANYEVENT_NET_TESTS environment variable not set\n";
9 exit 0; 12 exit 0;
10} 13}
14my $cv = AnyEvent->condvar; 17my $cv = AnyEvent->condvar;
15 18
16my $rbytes; 19my $rbytes;
17 20
18my $hdl; 21my $hdl;
19my $wo = AnyEvent::Util::tcp_connect ('www.google.com', 80, sub { 22my $wo = tcp_connect 'www.google.com', 80, sub {
20 my ($sock) = @_; 23 my ($fh) = @_;
24
21 $hdl = 25 $hdl =
22 AnyEvent::Handle->new ( 26 AnyEvent::Handle->new (
23 fh => $sock, 27 fh => $fh,
24 on_error => sub { 28 on_error => sub {
25 warn "socket error: $!"; 29 warn "socket error: $!";
26 $cv->broadcast; 30 $cv->broadcast;
27 }, 31 },
28 on_eof => sub { 32 on_eof => sub {
55 }); 59 });
56 }); 60 });
57 61
58 $hdl->push_write ("GET http://www.google.com/ HTTP/1.0\015\012\015\012"); 62 $hdl->push_write ("GET http://www.google.com/ HTTP/1.0\015\012\015\012");
59 63
60}, sub { 64};
61 warn "error on connect: $!";
62}, 10);
63 65
64$cv->wait; 66$cv->wait;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines