in reply to Re^3: AnyEvent::HTTP and getting data back from a post request
in thread AnyEvent::HTTP and getting data back from a post request

... I'm just not apparently getting any content back from the http_post - I'm not seeing the print statement

That doesn't sound right . I would use PERL_ANYEVENT_VERBOSE=1 perl yada... and maybe add

use AnyEvent::Strict;
and maybe add Devel::Trace (since AnyEvent::Trace is in the TODO que)

I think that the http_* methods work by making a call to the defined URL, and then process - upon completion of the http request sequence - the block that is the anonymous subroutine.... is that right?

Yes, http_* will invoke/call/execute the callback/nameless/anonymous-sub you pass, after its done what it can, either upon completion, or upon error -- the docs are very clear on this :)

Does the original code have the requisite loop or holding stuff to wait until all the http calls have been made, and responded? (I think this may actually be my problem.)

I think so. In fact, after reading some more documentation, I think with your original posted code, you could get rid of  my $cb = AnyEvent->condvar; and instead return

return http_post( ...
Then, instead of print Dumper(\@responses);
for my $response ( @responses ){ print "$response ", $response->recv, "\n"; }

Replies are listed 'Best First'.
Re^5: AnyEvent::HTTP and getting data back from a post request
by kiz (Monk) on Jan 27, 2011 at 16:13 UTC

    Chee-nious!!!

    Yep - that (mostly) did it (I'm hanging, never ending - but that is a minor issue just now):

    The Dumper print is telling me I'm not getting my basic authentication through:

    { 'URL' => 'http://user:pass@host.name/my/path', 'connection' => 'close', 'Status' => '401', 'HTTPVersion' => '1.1', 'date' => 'Thu, 27 Jan 2011 16:05:54 GMT', 'content-length' => '0', 'Reason' => 'Authorization Required', 'content-type' => 'text/plain', 'www-authenticate' => 'Basic realm="SWORD"', 'x-error-code' => 'ErrorAuth', 'server' => 'Apache/2.2.13 (Unix) mod_perl/2.0.4 Perl/v5.1 +0.0' }

    .... however - I have just found http://kobesearch.cpan.org/htdocs/AnyEvent-Twitter-Stream/AnyEvent/Twitter/Stream.pm.html - which seems to have a solution to authenticated access to we sites & getting data..



    -- Ian Stuart
    A man depriving some poor village, somewhere, of a first-class idiot.