php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74800 cURL Improperly Sets Proxy-Connect Header
Submitted: 2017-06-22 19:36 UTC Modified: -
From: cmanalio at gmail dot com Assigned:
Status: Open Package: cURL related
PHP Version: 7.0.20 OS: Centos 6.9
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: cmanalio at gmail dot com
New email:
PHP Version: OS:

 

 [2017-06-22 19:36 UTC] cmanalio at gmail dot com
Description:
------------
When using a proxy, the PHP Curl wrapper does not allow the user to remove or modify the Proxy-Connect header. PHP cURL will set a hard-coded "Proxy-Connect: Keep-alive" value, no matter if the user requests to disable this behavior by setting the header to null. Additionally, if the user would like to set "Proxy-Connect" to "Closed", this is impossible as cURL will still send the "Keep-Alive" header and append "Closed" afterwards, like so:
"Proxy-Connect: Keep-alive, Closed"

Test script:
---------------
<?php
//Proxy-Connection is not set, desired behavior is to remove this header from the request. The command line version of cURL does so properly, but PHP still sends it.
$headers = array('Proxy-Connection:');            

$ch = curl_init();
curl_setopt($ch, CURLOPT_PROXY, $GLOBALS['proxyserver']);
curl_setopt($ch, CURLOPT_URL, "http://www.xhaus.com/headers");
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
var_dump($result);

?>

Expected result:
----------------
HTTP Header*	Value
Accept	*/*
Connection	close
Host	www.xhaus.com
User-Agent	Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/29.0


Actual result:
--------------
HTTP Header*	Value
Accept	*/*
Connection	close
Host	www.xhaus.com
Proxy-Connection	Keep-Alive
User-Agent	Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/29.0


Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sat Nov 18 15:03:12 2017 UTC