1
stream_get_contents似乎不能正确处理持久(KeepAlive)连接。它在返回之前等待连接超时。默认情况下,Apache 2.2具有5秒的KeepAliveTimeout。我能做些什么吗? (除了禁用服务器上的KeepAlive,或使用protocol_version 1.0)stream_get_contents卡住持久(KeepAlive)连接
$opts = array('http' =>
array(
'method' => 'GET',
'protocol_version' => 1.1,
)
);
$context = stream_context_create($opts);
$stream = fopen('http://google.com', 'r', false, $context);
$metadata = stream_get_meta_data($stream);
$data = stream_get_contents($stream);
fclose($stream);
谢谢。
与循环+ feof()+ fread()相同的问题。 – goat