Skip to content

Commit 178d25f

Browse files
Update agent header (#40)
Set agent header Update metadata construction Update travis PHP version
1 parent 91adc9c commit 178d25f

File tree

4 files changed

+6
-10
lines changed

4 files changed

+6
-10
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: php
22
php:
33
- '5.5.38'
4-
- '5.6'
4+
- '5.6.25'
55
sudo: required
66
dist: trusty
77
install:

src/AgentHeaderDescriptor.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
*/
4040
class AgentHeaderDescriptor
4141
{
42-
const AGENT_HEADER_KEY = 'x-google-apis-agent';
42+
const AGENT_HEADER_KEY = 'x-goog-api-client';
4343

4444
private $clientName;
4545
private $clientVersion;
@@ -75,9 +75,9 @@ public function __construct($headerInfo)
7575
*/
7676
public function getHeader()
7777
{
78-
return [self::AGENT_HEADER_KEY => "$this->clientName/$this->clientVersion;".
78+
return [self::AGENT_HEADER_KEY => ["$this->clientName/$this->clientVersion;".
7979
"$this->codeGenName/$this->codeGenVersion;gax/$this->gaxVersion;".
80-
"php/$this->phpVersion"];
80+
"php/$this->phpVersion"]];
8181
}
8282

8383
private static function validate($descriptor)

src/ApiCallable.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,7 @@ private static function setCustomHeader($callable, $headerDescriptor)
130130
} else {
131131
$metadata = $params[self::GRPC_CALLABLE_METADATA_INDEX];
132132
$headers = $headerDescriptor->getHeader();
133-
if (array_key_exists('headers', $metadata)) {
134-
$headers = array_merge($headers, $metadata['headers']);
135-
}
136-
$params[self::GRPC_CALLABLE_METADATA_INDEX]['headers'] = $headers;
133+
$params[self::GRPC_CALLABLE_METADATA_INDEX] = array_merge($headers, $metadata);
137134
return call_user_func_array($callable, $params);
138135
}
139136
};

tests/ApiCallableTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,7 @@ public function testCustomHeader()
426426
$actualCalls = $stub->actualCalls;
427427
$this->assertEquals(1, count($actualCalls));
428428
$expectedMetadata = [
429-
'headers' =>
430-
['x-google-apis-agent' => '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']
431430
];
432431
$this->assertEquals($expectedMetadata, $actualCalls[0]['metadata']);
433432
}

0 commit comments

Comments
 (0)