php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60887 SoapClient ignores user_agent option and sends no User-Agent header
Submitted: 2012-01-25 20:45 UTC Modified: 2012-03-05 12:59 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: mail at tomsommer dot dk Assigned: dmitry (profile)
Status: Closed Package: SOAP related
PHP Version: 5.3.9 OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mail at tomsommer dot dk
New email:
PHP Version: OS:

 

 [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

Patches

Bug60887_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 Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-01-25 20:55 UTC] mail at tomsommer dot dk
The receiving server only receive the following headers:

GET / HTTP/1.1
Host: www.example.com
Connection: close

Checked with tcpdump
 [2012-01-26 07:16 UTC] mail at tomsommer dot dk
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));
 [2012-01-27 05:05 UTC] carloschilazo at gmail dot com
I could not reproduce your problem, using PHP 5.3.9 (linux) was able to send a 
request with user_agent header set


I captured with WireShark.... could you please try to:
a) capture with another program (maybe)
b) make sure that on the other end , the user_agent is not being stripped

or provide more info
 [2012-01-27 05:07 UTC] carloschilazo at gmail dot com
Forgot to mention, I tested with 5.3.9 realeased version, and also with the 
current snapshot
 [2012-01-27 10:45 UTC] mail at tomsommer dot dk
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'));
}
?>
 [2012-01-28 09:03 UTC] carloschilazo at gmail dot com
Oooh sorry, my bad; yeah you were right;

 I've posted a fix, I already tested it with no problem, waiting for someone to 
comment or commit.
 [2012-01-28 12:31 UTC] mail at tomsommer dot dk
Regarding your patch, I believe the header is "User-Agent", not "User Agent" :)
 [2012-01-28 17:41 UTC] carloschilazo at gmail dot com
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
 [2012-01-28 19:16 UTC] carloschilazo at gmail dot com
Checked it with "User-Agent" and the behavior is the same with and without the "-"

Better to be RFC compliant (RFC 2616) and add the '-;, I'll upload the patch 
again.

Thanks!
 [2012-01-29 00:55 UTC] carloschilazo at gmail dot com
After yawk@irc replicated the issue, the problem is that the WSDL request is the 
one that is not being sent with the user-agent header set.

Subsequent requests are.

Pending to determine if WSDL request should have user-agent set
 
(replication with screenshots: http://chilldata.com/dev/soapbug/)

Email will be sent to internals mailing list
 [2012-01-30 12:12 UTC] dmitry@php.net
-Assigned To: +Assigned To: dmitry
 [2012-03-05 12:58 UTC] dmitry@php.net
Automatic comment from SVN on behalf of dmitry
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=323909
Log: Fixed bug #60887 (SoapClient ignores user_agent option and sends no User-Agent header)
 [2012-03-05 12:59 UTC] dmitry@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 [2012-03-05 12:59 UTC] dmitry@php.net
-Status: Assigned +Status: Closed
 [2012-04-18 09:45 UTC] laruence@php.net
Automatic comment on behalf of dmitry
Revision: http://git.php.net/?p=php-src.git;a=commit;h=0add0bc021cebfbc08a29dbd983e0ca875e1a707
Log: Fixed bug #60887 (SoapClient ignores user_agent option and sends no User-Agent header)
 [2012-07-24 23:36 UTC] rasmus@php.net
Automatic comment on behalf of dmitry
Revision: http://git.php.net/?p=php-src.git;a=commit;h=0add0bc021cebfbc08a29dbd983e0ca875e1a707
Log: Fixed bug #60887 (SoapClient ignores user_agent option and sends no User-Agent header)
 [2013-11-17 09:33 UTC] laruence@php.net
Automatic comment on behalf of dmitry
Revision: http://git.php.net/?p=php-src.git;a=commit;h=0add0bc021cebfbc08a29dbd983e0ca875e1a707
Log: Fixed bug #60887 (SoapClient ignores user_agent option and sends no User-Agent header)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 08 09:01:33 2024 UTC