aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/php/lib
diff options
context:
space:
mode:
authorGravatar Stanley Cheung <stanleycheung@google.com>2015-11-08 18:16:58 -0800
committerGravatar Stanley Cheung <stanleycheung@google.com>2015-11-08 18:16:58 -0800
commit3baf76718e9e568d39710d29be9c838f11038d5c (patch)
tree8d7b19f1400fd07de0e3b2d6ee440ffe5244a9a8 /src/php/lib
parent555e8cc7976cfdc7801c0edaf1d25f97e1b9cfbd (diff)
php: append application user agent string at the beginning
Diffstat (limited to 'src/php/lib')
-rwxr-xr-xsrc/php/lib/Grpc/BaseStub.php8
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);
}