PHP cURL: modify/overwrite Connection header

With PHP cURL library I have ability to operate with HTTP headers, but how about Connection header? When I'm sending any request, cURL always appends it with Connection: Keep-Alive and when I'm trying to modify this header to this one Connection: keep-alive (lowercase 'keep-alive'), it append instead, two lines as result:

Connection: Keep-Alive
Connection: keep-alive

How can I change it instead of append? Thanks.

UPDATE: I'm doing it in this way:

$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);

UPDATE 1: Only solution I found (probably not the best) is to edit php_curl library file with hex editor.

链接地址: http://www.djcxy.com/p/87306.html

上一篇: 获取数据byc url,从访问的url下载javascpirt as xhr

下一篇: PHP cURL:修改/覆盖Connection标头