|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-01-25 20:45 UTC] mail at tomsommer dot dk
Description:
------------
The SoapClient ignores the "user_agent" option, and sends no User-Agent at all.
Test script:
---------------
$client = new SoapClient('http://www.example.com/', array('user_agent' => 'foo'));
Expected result:
----------------
User-Agent header on the remote server
Actual result:
--------------
No User-Agent header on the remote server
PatchesBug60887_user_agent_FIX_rfc2616_compliant (last revision 2012-01-28 19:19 UTC by carloschilazo at gmail dot com)60887_user_agent_FIX (last revision 2012-01-28 08:28 UTC by carloschilazo at gmail dot com) Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 07:00:01 2025 UTC |
Workaround is: $opts = array( 'http'=>array( 'user_agent' => 'foo' ) ); $context = stream_context_create($opts); $client = new SoapClient('http://www.example.com/', array('stream_context' => $context));I've tested it on several machines. It's not a matter of stripping the header, since stream_context works. My test script: <?php if ( isset($_GET['check']) ) { mail('you@example.com', 'ff', print_r(apache_request_headers(), true)); } else { $client = new SoapClient('http://example.com/soap.php?check=1', array('user_agent' => 'foo')); } ?>This is what I now get after running your script with my patch Array ( [DOCUMENT_ROOT] => /home/chilld/public_html [GATEWAY_INTERFACE] => CGI/1.1 [HTTP_CONNECTION] => close [HTTP_HOST] => pfdn.local.chilldata.com [HTTP_USER_AGENT] => foo [PATH] => /bin:/usr/bin [QUERY_STRING] => check=1 [REDIRECT_STATUS] => 200 [REMOTE_ADDR] => 189.253.78.75 [REMOTE_PORT] => 20615 [REQUEST_METHOD] => GET [REQUEST_URI] => /dev/soap.php?check=1 [SCRIPT_FILENAME] => /home/chilld/public_html/dev/soap.php [SCRIPT_NAME] => /dev/soap.php [SERVER_ADDR] => 10.34.11.56 [SERVER_ADMIN] => webmaster@chilldata.com [SERVER_NAME] => www.chilldata.com [SERVER_PORT] => 80 [SERVER_PROTOCOL] => HTTP/1.1 [SERVER_SIGNATURE] => [SERVER_SOFTWARE] => Apache [UNIQUE_ID] => TyOIZK3Hp1AAADUKGtYAAAAL [PHP_SELF] => /dev/soap.php [REQUEST_TIME] => 1327728740 [argv] => Array ( [0] => check=1 ) [argc] => 1 ) and if i change to see the $_SERVER['HTTP_USER_AGENT'] variable I get also foo