Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法通过perl套接字发送流水线http请求_Perl_Sockets_Http_Pipelining - Fatal编程技术网

无法通过perl套接字发送流水线http请求

无法通过perl套接字发送流水线http请求,perl,sockets,http,pipelining,Perl,Sockets,Http,Pipelining,我使用以下perl脚本通过sinlge tcp连接发送流水线http请求。第一个请求通过了,我能够得到响应。第二个请求也会被发送,但是没有收到对此请求的响应。我能够在跟踪中看到服务器上接收到的两个请求 use IO::Socket::INET; $| = 1; $socket = new IO::Socket::INET ( PeerHost => '10.102.218.56', PeerPort => '80', Proto => 'tcp',); di

我使用以下perl脚本通过sinlge tcp连接发送流水线http请求。第一个请求通过了,我能够得到响应。第二个请求也会被发送,但是没有收到对此请求的响应。我能够在跟踪中看到服务器上接收到的两个请求

use IO::Socket::INET;
$| = 1;

$socket = new IO::Socket::INET (
   PeerHost => '10.102.218.56',
   PeerPort => '80',
   Proto => 'tcp',);
die "cannot connect to the server $!\n" unless $socket;
print "connected to the server\n";

# data to send to a server
my $req = "GET /test/file5.html HTTP/1.1\r\nHost:10.102.218.50\r\nAccept: */*\r\n\r\n\r\n";
my $size = $socket->send($req);
print "1. sent data of length $size\n";

$socket->recv($response, 1024);
print "received response: $response\n";

my $req = "GET /test/file5.html HTTP/1.1\r\nHost:10.102.218.50\r\nAccept: */*\r\n\r\n\r\n";
my $size = $socket->send($req);
print "1. sent data of length $size\n";

$socket->recv($response, 1024);
print "received response: $response\n";
sleep 1;
$socket->close();
在Apache access_日志中,我只看到收到HTTP请求的一个实例:

10.102.218.50 - - [02/Sep/2014:23:04:50 +0530] "GET /test/file5.html HTTP/1.1" 200 6 "-" "-"
我猜我丢失了一些表示服务器HTTP请求结束的字符。但我无法找到它们是什么

我做错了什么

编辑:在第一个HTTP请求得到响应后,Apache服务器可能正在关闭连接。有这样的设置吗


Edit2:KeepAlive在我的apache服务器上被设置为关闭。将其设置为ON可修复此问题。

发现问题。在我的Apache服务器上,KeepAlive被设置为关闭。将KeepAlive设置为On修复了该问题