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: 2019-04-07 04:22 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: cmanalio at gmail dot com Assigned:
Status: No Feedback Package: cURL related
PHP Version: 7.0.20 OS: Centos 6.9
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [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

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-03-26 17:39 UTC] mike@php.net
-Status: Open +Status: Feedback
 [2019-03-26 17:39 UTC] mike@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.


 [2019-04-07 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Jul 12 22:01:25 2020 UTC