#!/usr/bin/perl -- use strict; use warnings; use AnyEvent::HTTP; use AnyEvent; AnyEvent->idle( cb => sub { print "\nidling @_\n" } ); my $cv = AnyEvent->condvar( cb => sub { warn "done"; } ); http_get ## schedule/cue up an event "http://localhost/test2", want_body_handle => 1, sub { warn "get one @_\n"; $cv->begin; #~ my ($handle, $hdr) = @_; my( $readFrom, $hdr ) = @_; $readFrom->on_eof( sub { $readFrom->destroy } ); my %headers = ( cookie => $hdr->{'set-cookie'}, ## for my server since same length => $hdr->{"content-length"}, type => $hdr->{"content-type"}, ); my $just_this_once = 0; http_post "http://localhost/test2?whatchyagot", undef, # NO BODY headers => \%headers, want_body_handle => 1, sub { return if $just_this_once; $just_this_once++; $cv->begin; warn "what is this @_\n"; my( $writeTo, $hdr ) = @_; $readFrom->on_read( sub { my $data = delete $_[0]{rbuf}; $writeTo->push_write( $data ); return; } ); return; }; return; }; $cv->end; ## MainLoop/run the program (do the get_ing and post_ing ) print '$cv->recv ', $cv->recv, "\n"; __END__ get one AnyEvent::Handle=HASH(0xd0ef24) HASH(0xbcc254) what is this AnyEvent::Handle=HASH(0xc0058c) HASH(0x9ef42c) Terminating on signal SIGINT(2)