diff options
author | Vincent JARDIN <vjardin@free.fr> | 2019-04-23 23:10:38 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-05-21 10:04:15 +0200 |
commit | 5f8c22d41536768298354218fe238691ae750f75 (patch) | |
tree | 95df7588f77fb1c1fd13d959fcd57591de37ed88 /ext/soap/php_http.c | |
parent | 202e6936d6fa319fdda16c5c61d70ce19c2ecef6 (diff) | |
download | php-git-5f8c22d41536768298354218fe238691ae750f75.tar.gz |
Support content_type stream context option in soap
Allows overriding the HTTP header using the HTTP context:
$client = new SoapClient('http://url.wsdl&v=latest', [
'stream_context' => stream_context_create([
'http' => [
'content_type' => 'foobarX',
],
]),
]);
This is a backport of c55af3c65ac116bbd935bd3d695869d88056c49c
to the PHP 7.2 branch.
Diffstat (limited to 'ext/soap/php_http.c')
-rw-r--r-- | ext/soap/php_http.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/ext/soap/php_http.c b/ext/soap/php_http.c index b894a1eabf..57754021b7 100644 --- a/ext/soap/php_http.c +++ b/ext/soap/php_http.c @@ -618,7 +618,16 @@ try_again: smart_str_append_smart_str(&soap_headers, &soap_headers_z); if (soap_version == SOAP_1_2) { - smart_str_append_const(&soap_headers,"Content-Type: application/soap+xml; charset=utf-8"); + if (context && + (tmp = php_stream_context_get_option(context, "http", "content_type")) != NULL && + Z_TYPE_P(tmp) == IS_STRING && + Z_STRLEN_P(tmp) > 0 + ) { + smart_str_append_const(&soap_headers, "Content-Type: "); + smart_str_appendl(&soap_headers, Z_STRVAL_P(tmp), Z_STRLEN_P(tmp)); + } else { + smart_str_append_const(&soap_headers, "Content-Type: application/soap+xml; charset=utf-8"); + } if (soapaction) { smart_str_append_const(&soap_headers,"; action=\""); smart_str_appends(&soap_headers, soapaction); @@ -626,7 +635,17 @@ try_again: } smart_str_append_const(&soap_headers,"\r\n"); } else { - smart_str_append_const(&soap_headers,"Content-Type: text/xml; charset=utf-8\r\n"); + if (context && + (tmp = php_stream_context_get_option(context, "http", "content_type")) != NULL && + Z_TYPE_P(tmp) == IS_STRING && + Z_STRLEN_P(tmp) > 0 + ) { + smart_str_append_const(&soap_headers, "Content-Type: "); + smart_str_appendl(&soap_headers, Z_STRVAL_P(tmp), Z_STRLEN_P(tmp)); + smart_str_append_const(&soap_headers, "\r\n"); + } else { + smart_str_append_const(&soap_headers, "Content-Type: text/xml; charset=utf-8\r\n"); + } if (soapaction) { smart_str_append_const(&soap_headers, "SOAPAction: \""); smart_str_appends(&soap_headers, soapaction); |