diff options
author | Stanley Cheung <stanleycheung@google.com> | 2015-11-08 18:16:58 -0800 |
---|---|---|
committer | Stanley Cheung <stanleycheung@google.com> | 2015-11-08 18:16:58 -0800 |
commit | 3baf76718e9e568d39710d29be9c838f11038d5c (patch) | |
tree | 8d7b19f1400fd07de0e3b2d6ee440ffe5244a9a8 /src/php/lib/Grpc/BaseStub.php | |
parent | 555e8cc7976cfdc7801c0edaf1d25f97e1b9cfbd (diff) |
php: append application user agent string at the beginning
Diffstat (limited to 'src/php/lib/Grpc/BaseStub.php')
-rwxr-xr-x | src/php/lib/Grpc/BaseStub.php | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/php/lib/Grpc/BaseStub.php b/src/php/lib/Grpc/BaseStub.php index c26be607ff..aa4de349ea 100755 --- a/src/php/lib/Grpc/BaseStub.php +++ b/src/php/lib/Grpc/BaseStub.php @@ -51,6 +51,7 @@ class BaseStub * @param $opts array * - 'update_metadata': (optional) a callback function which takes in a * metadata array, and returns an updated metadata array + * - 'grpc.primary_user_agent': (optional) a user-agent string */ public function __construct($hostname, $opts) { @@ -64,7 +65,12 @@ class BaseStub } $package_config = json_decode( 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']; $this->channel = new Channel($hostname, $opts); } |