|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77442 cURL ignores last header in CURLOPT_HTTPHEADER
Submitted: 2019-01-11 06:26 UTC Modified: 2019-04-07 04:22 UTC
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: stian at octetnest dot no Assigned:
Status: No Feedback Package: cURL related
PHP Version: 7.1.26 OS: Ubuntu 16.04
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.
Block user comment
Status: Assign to:
Bug Type:
From: stian at octetnest dot no
New email:
PHP Version: OS:


 [2019-01-11 06:26 UTC] stian at octetnest dot no
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) :

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_ENCODING => "application/xml",
    CURLOPT_HTTPHEADER => array_values($headers)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-02-28 18:46 UTC] 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-03-26 12:11 UTC]
-Status: Open +Status: Feedback
 [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-2021 The PHP Group
All rights reserved.
Last updated: Sun Apr 11 16:01:23 2021 UTC