Skip to content
This repository was archived by the owner on Jul 6, 2024. It is now read-only.

Commit 01ea343

Browse files
author
Dominik Zogg
committed
Drop headers
1 parent 4e946f4 commit 01ea343

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

src/Manager/ResponseManager.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,7 @@ public function createFromHttpException(
5353
;
5454

5555
$data = $httpException->jsonSerialize();
56-
57-
foreach ($data['headers'] ?? [] as $name => $value) {
58-
$response = $response->withHeader($name, $value);
59-
}
56+
$data['_type'] = 'apiProblem';
6057

6158
$body = $this->serializer->encode($data, $accept);
6259

tests/Unit/Manager/ResponseManagerTest.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,7 @@ public function testCreateRedirectWithoutDefaults(): void
174174

175175
public function testCreateFromHttpException(): void
176176
{
177-
$httpException = HttpException::createMethodNotAllowed([
178-
'headers' => ['Allow' => 'PATCH,PUT'],
179-
]);
177+
$httpException = HttpException::createMethodNotAllowed(['allowedMethods' => ['PATCH', 'PUT']]);
180178

181179
/** @var MockObject|StreamInterface $body */
182180
$body = $this->getMockByCalls(StreamInterface::class, [
@@ -186,7 +184,6 @@ public function testCreateFromHttpException(): void
186184
/** @var MockObject|Response $response */
187185
$response = $this->getMockByCalls(Response::class, [
188186
Call::create('withHeader')->with('Content-Type', 'application/problem+json')->willReturnSelf(),
189-
Call::create('withHeader')->with('Allow', 'PATCH,PUT')->willReturnSelf(),
190187
Call::create('getBody')->with()->willReturn($body),
191188
]);
192189

@@ -202,9 +199,8 @@ public function testCreateFromHttpException(): void
202199
'type' => 'https://datatracker.ietf.org/doc/html/rfc2616#section-10.4.6',
203200
'status' => 405,
204201
'title' => 'Method Not Allowed',
205-
'headers' => [
206-
'Allow' => 'PATCH,PUT',
207-
],
202+
'allowedMethods' => ['PATCH', 'PUT'],
203+
'_type' => 'apiProblem',
208204
], 'application/json')
209205
->willReturn('{"title":"Method Not Allowed"}'),
210206
]);

0 commit comments

Comments
 (0)