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: Open Package: SOAP related
PHP Version: 5.6.26 OS: Centos6
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [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

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Sep 16 06:01:27 2019 UTC