Skip to content

Commit 83815a5

Browse files
committed
Add default value for Accept header
1 parent cb07f11 commit 83815a5

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

HttpClientTrait.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ private static function prepareRequest(?string $method, ?string $url, array $opt
5656
}
5757
}
5858

59+
if (!isset($options['normalized_headers']['accept'])) {
60+
$options['normalized_headers']['accept'] = [$options['headers'][] = 'Accept: *'];
61+
}
62+
5963
if (isset($options['body'])) {
6064
$options['body'] = self::normalizeBody($options['body']);
6165
}

Tests/HttpClientTraitTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public function provideRemoveDotSegments()
172172
public function testAuthBearerOption()
173173
{
174174
[, $options] = self::prepareRequest('POST', 'http://example.com', ['auth_bearer' => 'foobar'], HttpClientInterface::OPTIONS_DEFAULTS);
175-
$this->assertSame(['Authorization: Bearer foobar'], $options['headers']);
175+
$this->assertSame(['Accept: *', 'Authorization: Bearer foobar'], $options['headers']);
176176
$this->assertSame(['Authorization: Bearer foobar'], $options['normalized_headers']['authorization']);
177177
}
178178

0 commit comments

Comments
 (0)