相关疑难解决方法(0)

无法限制PHP的cURL函数的下载大小

我正在使用PHP的cURL函数从steampowered.com读取配置文件.检索的数据是XML,只需要大约1000个字节.

我正在使用的方法是添加一个Range标头,我在Stack Overflow应答中读到(curl:如何限制GET的大小?).我尝试的另一种方法是使用curlopt_range,但这也不起作用.

<?
$curl_url = 'http://steamcommunity.com/id/edgen?xml=1';
$curl_handle = curl_init($curl_url);

curl_setopt ($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt ($curl_handle, CURLOPT_HTTPHEADER, array("Range: bytes=0-1000"));

$data_string = curl_exec($curl_handle);

echo $data_string;

curl_close($curl_handle);
?>
Run Code Online (Sandbox Code Playgroud)

执行此代码时,它返回整个代码.

我使用的是PHP 5.2.14版.

php curl http-headers

11
推荐指数
1
解决办法
3585
查看次数

标签 统计

curl ×1

http-headers ×1

php ×1