I couldn't see any way to make this work with existing CPAN packaged, so I made my own module to do HTTP Get with NTLM auth AnyEvent asynronously in case anyone cares and wants to build on this:
package AnyEventHTTPGetNTLM; use strict; use warnings; use AnyEvent; use AnyEvent::HTTP; use Authen::NTLM; # # AnyEventHTTPGetNTLM # # Uses AnyEvent::HTTP and Authen::NTLM to do an async HTTP GET on a NT +LM protected server. # Requires a hash ref as argument containing: # user => NTLM user name # pass => NTLM password # domain => NTLM domain # url => The URL to get # timeout => Time out of HTTP requests # cb => Call back subroutine, which will be called with result ($data +, $headers) as arguments. # # Returns object which must be kept in scope for callback. # The objects 'cv' item is a condition var for the overall async opera +tion. # sub new { my ($class,$args) = @_; my $self = $args; bless $self, $class; $self->{'cv'} = AnyEvent->condvar; $self->{'timeout'} = 10 if (!$self->{'timeout'}); $self->{'sub'} = sub { my ($data, $headers) = @_; if (($headers->{'Status'} eq '401') && ($headers->{'www-authen +ticate'} eq 'NTLM')) { ntlm_domain($self->{'domain'}); ntlm_user($self->{'user'}); ntlm_password($self->{'pass'}); my $auth = "NTLM ".ntlm(); ntlm_reset(); $self->{'cv'}->begin; $self->{'phase1'} = http_request GET => $self->{'url'}, ti +meout => $self->{'timeout'}, headers => {'Authorization' => $auth }, +presistent => 1, $self->{'sub'}; } elsif (($headers->{'Status'} eq '401') && ($headers->{'www-aut +henticate'} =~ m/^NTLM /)) { my $challange = $headers->{'www-authenticate'}; $challange =~ s/^NTLM //; ntlm(); my $auth = "NTLM ".ntlm($challange); ntlm_reset(); $self->{'cv'}->begin; $self->{'phase2'} = http_request GET => $self->{'url'}, ti +meout => $self->{'timeout'}, headers => {'Authorization' => $auth }, +persistent => 1, $self->{'sub'}; } else { $self->{'cb'}->($data,$headers); } $self->{'cv'}->end; }; $self->{'cv'}->begin; $self->{'phase0'} = http_request GET => $self->{'url'}, timeout => + $self->{'timeout'}, persistent => 1, $self->{'sub'}; return $self; } 1;
Example usage:
use AnyEventHTTPGetNTLM; use Data::Dumper qw(Dumper); my $async = new AnyEventHTTPGetNTLM({ 'domain' => 'myDomain', 'user' => 'fred', 'pass' => 'secret', 'url' => 'http://example.com:999/getsomething', 'timeout' => 10, 'cb' => sub { my ($data,$headers) = @_; print Dumper $headers; print Dumper $data; }, }); $async->{'cv'}->recv;

In reply to Re: AnyEvent::HTTP::LWP::UserAgent with LWP::Authen::NTLM causes recusrive blocking wait? by sectokia
in thread AnyEvent::HTTP::LWP::UserAgent with LWP::Authen::NTLM causes recusrive blocking wait? by sectokia

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.