如何在没有LWP :: UserAgent或HTTP :: Request的情况下在Perl中发送HTTPS请求? [英] How can I send an HTTPS request in Perl without LWP::UserAgent or HTTP::Request?

查看:217
本文介绍了如何在没有LWP :: UserAgent或HTTP :: Request的情况下在Perl中发送HTTPS请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在不使用LWP :: UserAgent或HTTP :: request的情况下发送HTTPS请求吗?这样做的另一种方法是什么?这是我需要发送的请求:

I need to send an HTTPS request without using LWP::UserAgent or HTTP::request? What is another method of doing so? This is the request I need to send:

POST https://payflowpro.paypal.com/
Connection: close
Host: payflowpro.paypal.com
Content-Length: 181
Content-Type: text/namevalue
X-VPS-CLIENT-TIMEOUT: 30
X-VPS-REQUEST-ID: 1249403513SNOID
X-VPS-VIT-INTEGRATION-PRODUCT: Product
X-VPS-VIT-INTEGRATION-VERSION: 4.0
X-VPS-VIT-OS-NAME: linux
X-VPS-VIT-OS-VERSION: 2.6.16-gentoo-r13
X-VPS-VIT-RUNTIME-VERSION: 5.008007

EXPDATE[4]=1011&AMT[6]=100.01&ACCT[16]=4111111111111111&TENDER[1]=C&TAXAMT[4]=0.00&PARTNER[8]=******&PWD[9]=******&VENDOR[6]=******&USER[6]=******&TRXTYPE[1]=S&VERBOSITY=MEDIUM


推荐答案

感谢SinanÜnür的包装参考我能够完成我需要的工作:

Thanks to package reference by Sinan Ünür I was able to accomplish what I needed:

my $host = 'pilot-payflowpro.paypal.com';
my $port = 443;
my $sock = IO::Socket::SSL->new("$host:$port") || die $!;

my $req = 'EXPDATE[4]=1011&AMT[6]=100.01&ACCT[16]=4111111111111111&TENDER[1]=C&TAXAMT[4]=0.00&PARTNER[8]=*****&PWD[9]=******&VENDOR[6]=*****&USER[6]=******&TRXTYPE[1]=S&VERBOSITY=MEDIUM';

print $sock "POST https://$host/ HTTPS/1.1\r\n";
print $sock "Connection: close", "\r\n";
print $sock "Host: ", $host, "\r\n";
print $sock "Content-length: ", length $req, "\r\n";
print $sock "Content-type: text/namevalue\r\n";
print $sock "X-VPS-CLIENT-TIMEOUT: 30", "\r\n";
print $sock "X-VPS-REQUEST-ID: 1249403513SNOID", "\r\n";
print $sock "X-VPS-VIT-INTEGRATION-PRODUCT: Product", "\r\n";
print $sock "X-VPS-VIT-INTEGRATION-VERSION: 4.0", "\r\n";
print $sock "X-VPS-VIT-OS-NAME: linux", "\r\n";
print $sock "X-VPS-VIT-OS-VERSION: 2.6.16-gentoo-r13", "\r\n";
print $sock "X-VPS-VIT-RUNTIME-VERSION: 5.008007", "\r\n\r\n";
print $sock $req, "\r\n\r\n";

print while <$sock>;

close $sock;

这篇关于如何在没有LWP :: UserAgent或HTTP :: Request的情况下在Perl中发送HTTPS请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆