php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73182 PHP SOAPClient does not support stream context HTTP headers in array form
Submitted: 2016-09-27 11:44 UTC Modified: -
From: scottie at live dot com Assigned:
Status: Closed Package: SOAP related
PHP Version: 5.6.26 OS: Centos6
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: scottie at live dot com
New email:
PHP Version: OS:

 

 [2016-09-27 11:44 UTC] scottie at live dot com
Description:
------------
When creating a stream context with http headers as a numerically indexed array this is ignored by SOAPClient (works as expected) with a string of headers. The documentation for the HTTP stream context says an array is supported.

In soap/php_http.c where the context headers are queried it appears that arrays are ignored. This also seems to be the case in PHP 7.

void http_context_headers(php_stream_context* context,
                          zend_bool has_authorization,
                          zend_bool has_proxy_authorization,
                          zend_bool has_cookies,
                          smart_str* soap_headers)
{
	zval *tmp;

	if (context &&
		(tmp = php_stream_context_get_option(context, "http", "header")) != NULL &&
		Z_TYPE_P(tmp) == IS_STRING && Z_STRLEN_P(tmp)) {

Test script:
---------------
$wdsl = 'path_to_wdsl';
$headers = array('Accept: application/soap+xml', 
                 'X-Custom: customheader');
$context = stream_context_create(array('http' => array('header' => $headers)));
$client = new SoapClient($wdsl, array('cache_wsdl' => WSDL_CACHE_NONE, 'stream_context' => $context, 'trace'=>1));

// do SOAP request
//$client->__doRequest(string $request , string $location , string $action , int $version);

echo $client->__getLastRequestHeaders());

Expected result:
----------------
Expect to see the headers added to request but not seen unless string form is used


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2024-09-10 18:24 UTC] git@php.net
Automatic comment on behalf of nielsdos
Revision: https://github.com/php/php-src/commit/72a2cbcc7f45058469cb369d1ebfad7bc83cc72a
Log: Fix bug #73182: PHP SOAPClient does not support stream context HTTP headers in array form
 [2024-09-10 18:24 UTC] git@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 13:01:29 2024 UTC