Skip to content
Snippets Groups Projects
Commit 0dd67a10 authored by Michael Lumish's avatar Michael Lumish
Browse files

Merge pull request #4090 from stanley-cheung/php_add_app_user_agent_string

PHP: append application user agent string at the beginning
parents bf94551b 3baf7671
No related branches found
No related tags found
No related merge requests found
...@@ -51,6 +51,7 @@ class BaseStub ...@@ -51,6 +51,7 @@ class BaseStub
* @param $opts array * @param $opts array
* - 'update_metadata': (optional) a callback function which takes in a * - 'update_metadata': (optional) a callback function which takes in a
* metadata array, and returns an updated metadata array * metadata array, and returns an updated metadata array
* - 'grpc.primary_user_agent': (optional) a user-agent string
*/ */
public function __construct($hostname, $opts) public function __construct($hostname, $opts)
{ {
...@@ -64,7 +65,12 @@ class BaseStub ...@@ -64,7 +65,12 @@ class BaseStub
} }
$package_config = json_decode( $package_config = json_decode(
file_get_contents(dirname(__FILE__).'/../../composer.json'), true); file_get_contents(dirname(__FILE__).'/../../composer.json'), true);
$opts['grpc.primary_user_agent'] = if (!empty($opts['grpc.primary_user_agent'])) {
$opts['grpc.primary_user_agent'] .= ' ';
} else {
$opts['grpc.primary_user_agent'] = '';
}
$opts['grpc.primary_user_agent'] .=
'grpc-php/'.$package_config['version']; 'grpc-php/'.$package_config['version'];
$this->channel = new Channel($hostname, $opts); $this->channel = new Channel($hostname, $opts);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment