Bug #77442 [Opn->Fbk]: cURL ignores last header in CURLOPT_HTTPHEADER
| From: | mike@php.net | Date: | Tue, 26 Mar 2019 12:11:52 +0000 |
| Subject: | Bug #77442 [Opn->Fbk]: cURL ignores last header in CURLOPT_HTTPHEADER | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-220185@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77442&edit=1
ID: 77442
Updated by: mike@php.net
Reported by: stian at octetnest dot no
Summary: cURL ignores last header in CURLOPT_HTTPHEADER
-Status: Open
+Status: Feedback
Type: Bug
Package: cURL related
Operating System: Ubuntu 16.04
PHP Version: 7.1.26
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2019-02-28 18:46:57] kontakt at beberlei dot de
I cannot reproduce this on 7.1 and ubuntu 18.04.
Could you say which vrsion of curl are you using from phpinfo? I have cURL Information => 7.58.0
One thing that I think is the cause is the "X-Trace" header. Is there an extension
injecting this header? It isn't in your list of curl_setopt_array
------------------------------------------------------------------------
[2019-01-11 06:26:49] stian at octetnest dot no
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 this bug report at https://bugs.php.net/bug.php?id=77442&edit=1