Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita5d76d7

Browse files
[ErrorHandler] Fix sending Vary header with SerializerErrorRenderer
1 parent46b6994 commita5d76d7

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

‎src/Symfony/Component/ErrorHandler/ErrorRenderer/SerializerErrorRenderer.php‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ public function __construct(SerializerInterface $serializer, $format, ErrorRende
5555
*/
5656
publicfunctionrender(\Throwable$exception):FlattenException
5757
{
58-
$headers = [];
58+
$headers = ['Vary' =>'Accept'];
59+
5960
$debug =\is_bool($this->debug) ?$this->debug : ($this->debug)($exception);
6061
if ($debug) {
6162
$headers['X-Debug-Exception'] =rawurlencode($exception->getMessage());
@@ -66,19 +67,17 @@ public function render(\Throwable $exception): FlattenException
6667

6768
try {
6869
$format =\is_string($this->format) ?$this->format : ($this->format)($flattenException);
69-
$headers = [
70-
'Content-Type' => Request::getMimeTypes($format)[0] ??$format,
71-
'Vary' =>'Accept',
72-
];
70+
$headers['Content-Type'] = Request::getMimeTypes($format)[0] ??$format;
7371

74-
return$flattenException->setAsString($this->serializer->serialize($flattenException,$format, [
72+
$flattenException->setAsString($this->serializer->serialize($flattenException,$format, [
7573
'exception' =>$exception,
7674
'debug' =>$debug,
77-
]))
78-
->setHeaders($flattenException->getHeaders() +$headers);
75+
]));
7976
}catch (NotEncodableValueException$e) {
80-
return$this->fallbackErrorRenderer->render($exception);
77+
$flattenException =$this->fallbackErrorRenderer->render($exception);
8178
}
79+
80+
return$flattenException->setHeaders($flattenException->getHeaders() +$headers);
8281
}
8382

8483
publicstaticfunctiongetPreferredFormat(RequestStack$requestStack):\Closure

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp