09:57:58.171573 IP 10.105.0.201.40128 > xxx.yyy.177.34.53: 18968+ SRV? _http._tcp.www.google.com. (43) 09:57:58.239373 IP xxx.yyy.177.34.53 > 10.105.0.201.40128: 18968 NXDomain 0/1/0 (93) 09:58:03.185482 ARP, Request who-has 10.105.0.1 tell 10.105.0.201, length 28 0x0000: 0001 0800 0604 0001 001e 4c67 1c5f 0a69 ..........Lg._.i 0x0010: 00c9 0000 0000 0000 0a69 0001 .........i.. 09:58:03.187671 ARP, Reply 10.105.0.1 is-at 00:90:0b:25:0b:71, length 28 0x0000: 0001 0800 0604 0002 0090 0b25 0b71 0a69 ...........%.q.i 0x0010: 0001 001e 4c67 1c5f 0a69 00c9 ....Lg._.i.. #### use AnyEvent ; use AnyEvent::Strict ; use AnyEvent::Handle; sub http_get { my ($host, $uri, $cb) = @_; print "http_get: $host, $uri called\n"; ###RPT # store results here #my ($response, $header, $body); my $handle; $handle = new AnyEvent::Handle connect => [$host => 'http'], on_error => sub { print "on_error: condition\n"; ###RPT $cb->("HTTP/1.0 500 $!"); $handle->destroy; # explicitly destroy handle }, on_eof => sub { print "on_eof: condition\n"; ###RPT $cb->($response, $header, $body); $handle->destroy; # explicitly destroy handle }; print "moving to push_write Get\n"; ###RPT $handle->push_write ("GET $uri HTTP/1.0\015\012\015\012"); print "after push_write Get\n"; ###RPT # now fetch response status line $handle->push_read (line => sub { my ($handle, $line) = @_; print "push_read: statusLine <$line>\n"; ###RPT $response = $line; }); # then the headers $handle->push_read (line => "\015\012\015\012", sub { my ($handle, $line) = @_; print "push_read: header <$line>\n"; ###RPT $header = $line; }); # and finally handle any remaining data as body $handle->on_read (sub { $body .= $_[0]->rbuf; print "on_read: body <$line>\n"; ###RPT $_[0]->rbuf = ""; }); } http_get "www.google.com", "/", sub { # my ($response, $header, $body) = @_; print $response, "\n", $header, "\n", ###RPT $body; };