PHP cURL:修改/覆盖Connection标头
使用PHP cURL库,我可以使用HTTP头进行操作,但Connection头怎么样? 当我发送任何请求时,cURL总是将它附加到Connection:Keep-Alive,并且当我试图将这个头部修改为这个Connection:keep-alive (小写'keep-alive')时,它会附加上两个结果如下:
Connection: Keep-Alive
Connection: keep-alive
我怎样才能改变它而不是追加? 谢谢。
更新:我这样做:
$url = 'http://some.host/path';
$ch = curl_init();
$hdrs = array( 'Host: some.host',
'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:42.0) Gecko/20100101 Firefox/42.0',
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language: en-US;q=0.5,en;q=0.3',
'Accept-Encoding: gzip, deflate',
'Connection: keep-alive');
curl_setopt($ch, CURLOPT_HTTPHEADER, $hdrs);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_VERBOSE, FALSE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
$data = curl_exec($ch);
更新1:只有我找到的解决方案(可能不是最好的)是用十六进制编辑器编辑php_curl库文件。
链接地址: http://www.djcxy.com/p/87305.html上一篇: PHP cURL: modify/overwrite Connection header
下一篇: Yii framework 1.1 get the http request Header in Controller action