I was going to suggest using AnyEvent::HTTP but a streaming request/PUT/POST/upload isn't supported ... I think it needs to register a on_body easily
Here is my clumsy attempt which kinda seems to work , two requests are made, but I've not verified that the body/content is sent to the 2nd one -- and it hangs
#!/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 s
+ame
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)
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.