我使用PHP的cURL函數從steampowered.com讀取配置文件。檢索的數據是XML,只需要大約1000字節。無法限制PHP的cURL函數的下載大小
我正在使用的方法是添加一個Range標題,我在堆棧溢出答案(curl: How to limit size of 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);
?>
當執行此代碼時,它將返回整個事物。
我正在使用PHP版本5.2.14。
你確定你要查詢的服務器支持範圍嗎?因爲當我從命令行嘗試時,我也得到了整個文檔,這導致我相信steamcommunity.com沒有啓用該功能 – Doon 2010-08-07 19:19:59