![](/img/trans.png)
[英]How can I send event data to Google Measurement Protocol via cURL without a browser generated user-agent?
[英]how i can curl Range and User-Agent
GET /folder/downloads/xx.zip HTTP/1.1
Range: bytes=0-6423263
User-Agent: Dalvik
Host: xx.xx.xxx.xxx:2050
Connection: Keep-Alive
Accept-Encoding: gzip
需要在 curl 中使用这个我尝试但不起作用可以给我真正的代码我尝试
$data = array('Range'=>"0-6423263");
curl_setopt($curl, CURLOPT_URL, "http://xx.xx.xxx.xxx:2050/folder/downloads/xx.zip");
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_POST, 0);
curl_setopt($curl, CURLOPT_HTTPGET, 1);
curl_setopt($curl, CURLOPT_USERAGENT, 'Dalvik');
$output = curl_exec($curl);
CURLOPT_POSTFIELDS
指定要 POST 到服务器的数据。 改为检查CURLOPT_RANGE 。
curl_setopt($curl, CURLOPT_RANGE, '0-6423263');
默认情况下 curl 自己使用 keep-alive 。 你不需要声明它。
对于Accept-Encoding
标头,请使用CURLOPT_ENCODING
curl_setopt($curl, CURLOPT_ENCODING, 'gzip');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.