我即将在这里丢失它,我正在尝试发送两个 HTTP 1.1 以获取我的一些 url 页面的源代码(我不想使用 LWP),并且只有第一个有效,即使我切换了顺序,所以理论上这两个请求都很好,这就是我所做的:
我什至创建了两个套接字以防万一,但结果相同......
my $sock = IO::Socket::INET->new(
PeerAddr => $dom,
PeerPort => 'http(80)',
Proto => 'tcp'
)
or die "Could not connect to :80!! $!";
my $sock2 = IO::Socket::INET->new(
PeerAddr => $dom,
PeerPort => 'http(80)',
Proto => 'tcp'
)
or die "Could not connect to :80!! $!";
my $req2 = << 'EOT'
POST / HTTP/1.1
Host: $dom
Connection: keep-alive
Content-Length: 57
Cache-Control: max-age=0
Origin: ${org}
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Referer: ${ref}
EOT
;
my $req = << 'EOT'
POST / HTTP/1.1
Host: $dom
Connection: keep-alive
Content-Length: 57
Cache-Control: max-age=0
Origin: ${org}
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Referer: ${ref}
EOT
;
$sock2->send($req2);
sleep 5;
my $abc;
while(<$sock2>) {
print $_;
}
$sock->send($req);
sleep 5;
while(<$sock>) {
print $_;
}
问题似乎出在哪里?
提前致谢。