title: LWP::UserAgent HTTP Basic Authentication
body: <p>I tried to run this perl5 program:</p>
  
  <pre><code> #!/usr/bin/env perl                                                             
  
  use strict;                                                                     
  use warnings;                                                                   
  use LWP;                                                                        
  
  my $ua = LWP::UserAgent-&gt;new('Mozilla');                                        
  $ua-&gt;credentials("test.server.com:39272", "realm-name", 'user_name', 'some_pass');                       
  my $res = $ua-&gt;get('http://test.server.com:39272/');                  
  
  print $res-&gt;content;
  </code></pre>
  
  <p>On other hand I have HTTP::Daemon:</p>
  
  <pre><code>#!/usr/bin/env perl                                                                                       
  
  use strict;                                                                     
  use warnings;                                                                   
  
  use HTTP::Daemon;                                                               
  
  my $hd = HTTP::Daemon-&gt;new or die;                                              
  
  print "Contact URL: ", $hd-&gt;url, "\n";                                          
  while (my $hc = $hd-&gt;accept) {                                                  
    while (my $hr = $hc-&gt;get_request) {                                           
      if ($hr-&gt;method eq 'GET') {                                                 
        print $hr-&gt;as_string, "\n";                                               
      }                                                                           
    }                                                                             
    $hc-&gt;close;                                                                   
    undef($hc);                                                                   
  }    
  </code></pre>
  
  <p>And it just prints:</p>
  
  <pre><code>Contact URL: http://test.server.com:39272/
  GET / HTTP/1.1
  Connection: TE, close
  Host: test.server.com:39272
  TE: deflate,gzip;q=0.3
  User-Agent: libwww-perl/6.03
  </code></pre>
  
  <p>So I see that LWP::UserAgent don't send HTTP Basic auth, but I don't know why.</p>
  
  <p>I seen some post on this web site, but they have this same basic code, and it doesn't
  work...</p>
  
  <p>If I use HTTP::Request then it works:</p>
  
  <pre><code>my $req = GET 'http://test.server.com:39272/';                        
  $req-&gt;authorization_basic('my_id', 'my_pass');                                  
  my $res = $ua-&gt;request($req);
  </code></pre>
  
  <p>Outputs:</p>
  
  <pre><code>GET / HTTP/1.1
  Connection: TE, close
  Authorization: Basic bXlfaWQ6bXlfcGFzcw==
  Host: test.server.com:39272
  TE: deflate,gzip;q=0.3
  User-Agent: libwww-perl/6.03
  </code></pre>
  
  <p>Did I done something wrong before?</p>