Bug #77442 [Fbk->NoF]: cURL ignores last header in CURLOPT_HTTPHEADER

From: Date: Sun, 07 Apr 2019 04:22:05 +0000
Subject: Bug #77442 [Fbk->NoF]: cURL ignores last header in CURLOPT_HTTPHEADER
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-220349@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: php-bugs@lists.php.net Reported by: stian at octetnest dot no Summary: cURL ignores last header in CURLOPT_HTTPHEADER -Status: Feedback +Status: No Feedback Type: Bug Package: cURL related Operating System: Ubuntu 16.04 PHP Version: 7.1.26 Private report: N New Comment: 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. 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

« previous php.bugs (#220349) next »