Add default value for Accept header

This commit is contained in:
geoffrey 2019-09-16 21:06:04 +02:00
parent c300a71414
commit 48eebfc77b
2 changed files with 5 additions and 1 deletions

View File

@ -56,6 +56,10 @@ trait HttpClientTrait
}
}
if (!isset($options['normalized_headers']['accept'])) {
$options['normalized_headers']['accept'] = [$options['headers'][] = 'Accept: *'];
}
if (isset($options['body'])) {
$options['body'] = self::normalizeBody($options['body']);
}

View File

@ -172,7 +172,7 @@ class HttpClientTraitTest extends TestCase
public function testAuthBearerOption()
{
[, $options] = self::prepareRequest('POST', 'http://example.com', ['auth_bearer' => 'foobar'], HttpClientInterface::OPTIONS_DEFAULTS);
$this->assertSame(['Authorization: Bearer foobar'], $options['headers']);
$this->assertSame(['Accept: *', 'Authorization: Bearer foobar'], $options['headers']);
$this->assertSame(['Authorization: Bearer foobar'], $options['normalized_headers']['authorization']);
}