Bug #77442 [NEW]: cURL ignores last header in CURLOPT_HTTPHEADER
| From: | stian at octetnest dot no | Date: | Fri, 11 Jan 2019 06:26:49 +0000 |
| Subject: | Bug #77442 [NEW]: cURL ignores last header in CURLOPT_HTTPHEADER | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-218894@lists.php.net to get a copy of this message | ||
From: stian at octetnest dot no
Operating system: Ubuntu 16.04
PHP version: 7.1.26
Package: cURL related
Bug Type: Bug
Bug description:cURL ignores last header in CURLOPT_HTTPHEADER
Description:
------------
cURL seems to always ignore the last header set through
CURLOPT_HTTPHEADER. When I inspect outgoing requests with Wireshark, it
consistently shows that the last header in an headers array provided to
cURL gets ignored. For the headers provided in the 'Test Script' field,
this is what Wireshark reports (The 'X-Remove' header is gone) :
POST [REMOVED] HTTP/1.1
Host: [REMOVED]
Accept: */*
Accept-Encoding: application/xml
X-External-User-ID: 1
X-Territory-ID: 9b0a8426-1493-4997-aab0-2d0de736225a
X-Company-Name: Company Name
X-File-Quality: 1
X-File-Type: JPG
X-Filename-Prefix: prefix
X-Title: Title
Authorization: Basic dGVzdDp0ZXN0
X-Trace: 2B2B1AB863BA48CFF980DCE0B5CD3C3FE7DD4E68390B4A407CEEBFEBC601
If I take out the 'X-Remove' header, then cURL will ignore the
'Authorization' header.
Test script:
---------------
$headers = array(
'X-External-User-ID: 1',
'X-Territory-ID: 9b0a8426-1493-4997-aab0-2d0de736225a',
'X-Company-Name: Company Name',
'X-File-Quality: 1',
'X-File-Type: JPG',
'X-Filename-Prefix: prefix',
'X-Title: Title',
'Authorization: Basic dGVzdDp0ZXN0',
'X-Remove: This header will be removed by curl',
);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "application/xml",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 3,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_HEADER => 1,
CURLOPT_HTTPHEADER => array_values($headers)
));
--
Edit bug report at https://bugs.php.net/bug.php?id=77442&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77442&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77442&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77442&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=77442&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=77442&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=77442&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=77442&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=77442&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=77442&r=support
Expected behavior: https://bugs.php.net/fix.php?id=77442&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=77442&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=77442&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=77442&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77442&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=77442&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=77442&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=77442&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77442&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=77442&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=77442&r=mysqlcfg