Hi,
Writing a client for a REST api that I created. The client works approximately half the time. Here's a simple version that can recreate the problem:
#!/usr/bin/env perl
use v5.18;
use strict;
use warnings;
use Mojo::UserAgent;
use MIME::Base64;
use Data::Dumper;
my $ua = Mojo::UserAgent->new();
my $user = "scot-alerts";
my $pass = "xxxx";
my $auth = "Basic ".encode_base64($user.":".$pass);
$ua->on( start => sub {
my $ua = shift;
my $tx = shift;
$tx->req->headers->header(
'Authorization' => $auth
);
});
my $results = {};
for my $i (1..100) {
my $tx = $ua->get(
);
my $code = $tx->res->code;
$results->{$code}++;
}
say Dumper($results);
Three runs of the above yield:
$VAR1 = {
'200' => 49,
'400' => 51
};
$VAR1 = {
'200' => 50,
'400' => 50
};
$VAR1 = {
'400' => 55,
'200' => 45
};
I do see the following in the apache2 error log:
AH02031: Hostname myservername provided via SNI, but no hostname provided in HTTP request
I've tried adding the "Host" header (set to myservername) when I set the "Authorization" header, but that didn't change anything.
System is Ubuntu 14.04, Apache/2.4.7 (Ubuntu), Perl 5.18.2, up to date Mojo::UserAgent (cpanm claims it is up to date anyway)
Any ideas what I'm doing wrong? Thanks!
Todd