Skip to content

Commit 93d2939

Browse files
Update headers (#47)
- Fix capitalization - Add gax version - Change to space-separated - Add todo and issue
1 parent fbf26eb commit 93d2939

File tree

4 files changed

+21
-10
lines changed

4 files changed

+21
-10
lines changed

src/AgentHeaderDescriptor.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
class AgentHeaderDescriptor
4141
{
4242
const AGENT_HEADER_KEY = 'x-goog-api-client';
43+
// TODO(michaelbausor): include bumping this version in a streamlined
44+
// release process. Issue: https://github.com/googleapis/gax-php/issues/48
45+
const GAX_VERSION = '0.5.0-dev';
4346

4447
private $clientName;
4548
private $clientVersion;
@@ -75,11 +78,19 @@ public function __construct($headerInfo)
7578
*/
7679
public function getHeader()
7780
{
78-
return [self::AGENT_HEADER_KEY => ["$this->clientName/$this->clientVersion;".
79-
"$this->codeGenName/$this->codeGenVersion;gax/$this->gaxVersion;".
81+
return [self::AGENT_HEADER_KEY => ["$this->clientName/$this->clientVersion ".
82+
"$this->codeGenName/$this->codeGenVersion gax/$this->gaxVersion ".
8083
"php/$this->phpVersion"]];
8184
}
8285

86+
/**
87+
* Returns the version string for GAX.
88+
*/
89+
public static function getGaxVersion()
90+
{
91+
return self::GAX_VERSION;
92+
}
93+
8394
private static function validate($descriptor)
8495
{
8596
$requiredFields = ['clientName', 'clientVersion', 'codeGenName',

src/GrpcCredentialsHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function createCallCredentialsCallback()
100100
$credentialsLoader = $this->credentialsLoader;
101101
$callback = function () use ($credentialsLoader) {
102102
$token = $credentialsLoader->fetchAuthToken();
103-
return ['Authorization' => array('Bearer ' . $token['access_token'])];
103+
return ['authorization' => array('Bearer ' . $token['access_token'])];
104104
};
105105
return $callback;
106106
}

tests/ApiCallableTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ public function testCustomHeader()
426426
$actualCalls = $stub->actualCalls;
427427
$this->assertEquals(1, count($actualCalls));
428428
$expectedMetadata = [
429-
'x-goog-api-client' => ['testClient/0.0.0;testCodeGen/0.9.0;gax/1.0.0;php/5.5.0']
429+
'x-goog-api-client' => ['testClient/0.0.0 testCodeGen/0.9.0 gax/1.0.0 php/5.5.0']
430430
];
431431
$this->assertEquals($expectedMetadata, $actualCalls[0]['metadata']);
432432
}

tests/GrpcCredentialsHelperTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function testCreateCallCredentialsCallbackDefault()
5252
$grpcCredentialsHelper = new GrpcCredentialsHelperForTesting($this->defaultScope);
5353
$callback = $grpcCredentialsHelper->createCallCredentialsCallback();
5454
$callbackResult = $callback();
55-
$this->assertEquals(['Bearer adcAccessToken'], $callbackResult['Authorization']);
55+
$this->assertEquals(['Bearer adcAccessToken'], $callbackResult['authorization']);
5656
}
5757

5858
public function testCreateCallCredentialsCallbackCustomCredsLoader()
@@ -62,7 +62,7 @@ public function testCreateCallCredentialsCallbackCustomCredsLoader()
6262
$this->defaultScope, $this->defaultTokens)]);
6363
$callback = $grpcCredentialsHelper->createCallCredentialsCallback();
6464
$callbackResult = $callback();
65-
$this->assertEquals(['Bearer accessToken'], $callbackResult['Authorization']);
65+
$this->assertEquals(['Bearer accessToken'], $callbackResult['authorization']);
6666
}
6767

6868
public function testCreateCallCredentialsCallbackDisableCaching()
@@ -73,10 +73,10 @@ public function testCreateCallCredentialsCallbackDisableCaching()
7373
'enableCaching' => false]);
7474
$callback = $grpcCredentialsHelper->createCallCredentialsCallback();
7575
$callbackResult = $callback();
76-
$this->assertEquals(['Bearer accessToken'], $callbackResult['Authorization']);
76+
$this->assertEquals(['Bearer accessToken'], $callbackResult['authorization']);
7777
$callback = $grpcCredentialsHelper->createCallCredentialsCallback();
7878
$callbackResult = $callback();
79-
$this->assertEquals(['Bearer accessToken2'], $callbackResult['Authorization']);
79+
$this->assertEquals(['Bearer accessToken2'], $callbackResult['authorization']);
8080
}
8181

8282
public function testCreateCallCredentialsCallbackCaching()
@@ -86,10 +86,10 @@ public function testCreateCallCredentialsCallbackCaching()
8686
$this->defaultScope, $this->defaultTokens)]);
8787
$callback = $grpcCredentialsHelper->createCallCredentialsCallback();
8888
$callbackResult = $callback();
89-
$this->assertEquals(['Bearer accessToken'], $callbackResult['Authorization']);
89+
$this->assertEquals(['Bearer accessToken'], $callbackResult['authorization']);
9090
$callback = $grpcCredentialsHelper->createCallCredentialsCallback();
9191
$callbackResult = $callback();
92-
$this->assertEquals(['Bearer accessToken'], $callbackResult['Authorization']);
92+
$this->assertEquals(['Bearer accessToken'], $callbackResult['authorization']);
9393
}
9494

9595
public function testCreateStubWithDefaultSslCreds()

0 commit comments

Comments
 (0)