AnyEvent::HTTP and basic authentication

Marc Lehmann schmorp at schmorp.de
Tue Feb 1 18:31:50 CET 2011


On Tue, Feb 01, 2011 at 04:33:20PM +0000, Ian Stuart <Ian.Stuart at ed.ac.uk> wrote:
>     my $auth = "Basic ".MIME::Base64::encode("$username:$password", '');
>     my %headers = (
>         'Authorization'       => $auth,
>                   );
>     # this is a long call, intersperced with comments!
>     http_request(
> 
>         # the main request we want to make
>         "POST", "http://'.$host.$collection,
> 
>         # the body of the http_request
>         body => $archive,
> 
>         # the headers for that request
>         headers => \%headers,
> 
>         $cv
>     );
> 
> work....
> (credentials proven to work using LWP::UserAgent)

Thats exactly how one would do it, yes - I guess either your credentials
are wrong, basic auth isn't supported by the other side, authorisation
isn't actually the problem or that is not the code you are using.

Most web servers expect a content-type header - maybe this is your
problem? What status does the server return when you try?

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp at schmorp.de
      -=====/_/_//_/\_,_/ /_/\_\



More information about the anyevent mailing list