Issues

ZF-8053: There is no way to set custom user-agent to Zend_Soap_Client

Description

Method setOptions doesn't allow user_agent option. But this is only one possibility to customize user-agent. I don't know why it's not allowed. Probably one reason is to allow to user customize user-agent via stream_context, but it doesn't work:


$opts = array('http' =>
    array(
        'user_agent' => 'custom'
    )
);
$context  = stream_context_create($opts);

$client = new SoapClient($wsdl, 
    array( 
        'context_stream' => $context
        //'user_agent' => 'custom'
    )
);

It's probably supposed to work, but it isn't. The only one way to customize user-agen - is to uncomment 'user_agent' option.

I've descovered only one way to do it without changes in ZF:


protected function _initTestSoapClient($wsdl) {
        $client = new Zend_Soap_Client($wsdl);
        $options = array_merge($client->getOptions(), array(
            'user_agent' => 'custom'
        ));
        $soapClient = new Zend_Soap_Client_Common(array($client, '_doRequest'), $wsdl, $options);
        $client->setSoapClient($soapClient);
        return $client;
    }

It doesn't seem good, so, I believe introducing new available option in setOptions is a reasonable idea.

Comments

Fixed in trunk (r18569) and in 1.9-release branch (r18570)