https サーバーに対して機能する LWP 要求を取得しようとしています。ユーザーとパスが与えられ、基本認証を使用するようにアドバイスされました。さまざまなコードのチャンクを試しましたが、すべて認証エラーが発生するようです。私の現在のコードは...
use warnings;
use strict;
use Data::Dumper;
use LWP;
my $ua = LWP::UserAgent->new( keep_alive => 1 );
##also tried by $ua->credentials('domain','','user','pass');
##not sure if I need 'realm' or how I get it, as no popup on screen.
my $request = HTTP::Request->new( GET => "https://my.url.com/somepath/" );
$request->authorization_basic('myuser','mypass');
$request->header( 'Cache-Control' => 'no-cache' );
print $response->content;
print Dumper $response;
サーバーはセキュリティ エラーを返しますが、$response のダンプを見ると、次のように表示されます...
'_rc' => '401',
'_headers' => bless( { .... lots of stuff
'title' => 'Security Exception',
'client-warning' => 'Missing Authenticate header',
'client-ssl-socket-class' => 'IO::Socket::SSL',
...
'expires' => '-1'
}, 'HTTP::Headers' ),
'_msg' => 'Unauthorized',
'_request' => bless( {
'_content' => '',
'_uri' => bless( do{\(my $o = 'https:theurlabove')}, 'URI::https' ),
'_method' => 'GET',
'_uri_canonical' => $VAR1->{'_request'}{'_uri'}
'_headers' => bless( {
'user-agent' => 'libwww-perl/6.04',
'cache-control' => 'no-cache',
'authorization' => 'Basic dzx..........'
}, 'HTTP::Headers' ),
何が起こっているのかを理解しようとしています。元のリクエストにはヘッダーが含まれているように見えますが、応答には「認証ヘッダーがありません」と表示されます。
コードに何か問題がありますか、それとも request/respinse で誤解していますか?
ありがとう。