gpt4 book ai didi

Perl HTTP 后认证

转载 作者:塔克拉玛干 更新时间:2023-11-01 19:09:51 27 4
gpt4 key购买 nike

只是想知道是否有人能看出为什么这没有将用户名和密码传递给 Web 服务器?

my $ua = LWP::UserAgent->new();
$ua->credentials("10.64.1.1:80", "realm-name", 'alexis','alexispass');
my $resp = $ua->post("http://10.64.1.1:80/CGI/Execute",
{ "Key" => "XML" ,
"value" => "<setBackground><background><image>http://10.64.2.2/7945-65 NFullSize.png</image><icon>http://10.64.2.2/7945-65/NThumSize.png</icon></background></setBackground>"});
print $resp->content;

谢谢亚历克西斯

最佳答案

也许这可以帮助你:

#!/usr/bin/perl -w
use strict;
use HTTP::Request::Common;
require LWP::UserAgent;
my $usr = 'alexis';
my $pass = 'alexispass';
my $URL = 'http://10.64.1.1:80/CGI/Execute';
my $ua = new LWP::UserAgent;
$ua->timeout(20);
my $request = POST $URL,
Content_Type => [ 'Content_Type here' ],
Content => [ 'Content here' ];

$request->authorization_basic($usr, $pass);
my $response = $ua->request($request);
print $response->content;

此脚本使用 HTTP::Request::Common 中的 POST() 函数。如果我理解正确的话,那部分你的 POST 请求应该是这样的:

my $request = POST $URL,
[ XML => '<setBackground><background><image>http://10.64.2.2/7945-65 NFullSize.png</image><icon>http://10.64.2.2/7945-65/NThumSize.png</icon></background></setBackground>'
];

该请求创建对象,它看起来像这样:

POST http://10.64.1.1:80/CGI/Execute
Content-Length: 66
Content-Type: application/x-www-form-urlencoded
XML=<setBackground><background><image>http://10.64.2.2/7945-65 NFullSize.png</image><icon>http://10.64.2.2/7945-65/NThumSize.png</icon></background></setBackground>

关于Perl HTTP 后认证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19842400/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com