Skip to content

Commit 2dc30b5

Browse files
committed
Make sure to add accept header
1 parent 653d4fe commit 2dc30b5

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/Github/Client.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ public function __construct(HttpClient $httpClient = null)
158158
$this->addPlugin(new Plugin\HeaderDefaultsPlugin(array(
159159
'User-Agent' => 'php-github-api (http://github.com/KnpLabs/php-github-api)',
160160
)));
161+
// Add standard headers.
162+
$this->clearHeaders();
161163
}
162164

163165
/**
@@ -430,6 +432,12 @@ public function setOption($name, $value)
430432
throw new InvalidArgumentException(sprintf('Undefined option called: "%s"', $name));
431433
}
432434

435+
if ($name === 'api_version') {
436+
$this->addHeaders([
437+
'Accept' => sprintf('application/vnd.github.%s+json', $value),
438+
]);
439+
}
440+
433441
$this->options[$name] = $value;
434442
}
435443

0 commit comments

Comments
 (0)