【发布时间】:2014-02-03 02:34:30
【问题描述】:
我创建了一个 Perl 脚本来运行一个 https 任务。当我运行它时,我收到错误 LWP::Protocol::https not installed。
我无法弄清楚或找到有关如何准确安装LWP::Protocol::http 的教程或命令。任何人都知道如何安装它?安装LWP 非常简单。
我已经安装了LWP 和Crypt-SSLeay,但是我仍然收到错误。这是我的代码:
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
# set custom HTTP request header fields
my $req = HTTP::Request->new(PUT => "https://thesite.com");
$req->header('Authorization' => 'myauth');
$req->header('Accept' => 'JSON:Application/JSON');
$req->header('Content-Type' => 'JSON:Application/JSON');
$req->header('Host' => 'api.thesite.com');
$req->content('Text' => 'thetext');
my $resp = $ua->request($req);
if ($resp->is_success) {
my $message = $resp->decoded_content;
print "Received reply: $message\n";
}
else {
print "HTTP POST error code: ", $resp->code, "\n";
print "HTTP POST error message: ", $resp->message, "\n";
}
【问题讨论】:
-
如果错误告诉你
LWP::Protocol::https没有安装,安装它。 -
天哪。这是糟糕的一天。我需要编辑这个问题。我太着急了,我没有做正确的事情......
-
cpan然后install LWP::Protocol::https或install Bundle::LWP -
伙计,我以为我试过了。好的,棒极了。现在正在安装。非常感谢您的快速帮助!