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(
        'https://myservername/myapp/api/v2/event/1' => {Accept => '*/*' }
    );

    my $code = $tx->res->code;
    $results->{$code}++;

}
say Dumper($results);

Three runs of the above yield:
perl simple.pl
$VAR1 = {
          '200' => 49,
          '400' => 51
        };
perl simple.pl
$VAR1 = {
          '200' => 50,
          '400' => 50
        };
perl simple.pl
$VAR1 = {
          '400' => 55,
          '200' => 45
        };

I'm not sure if the problem is with Apache Config or Client.  Web browser 
access to https://myservername/scot/api/v2/event/1 never fails.
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



-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to