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

Commitbf7c94d

Browse files
committed
[#6857] Re-wording the section a bit
1 parentbc83735 commitbf7c94d

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

‎reference/events.rst‎

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ and set a new ``Exception`` object, or do nothing::
241241

242242
..note::
243243

244-
If you want to overwrite the status code (which you should not without a good reason),
245-
set the ``X-Status-Code`` header::
244+
If you want to overwrite the status code (which you shoulddonot without a good
245+
reason), set the ``X-Status-Code`` header::
246246

247247
$response = new Response(
248248
'Error',
@@ -252,19 +252,20 @@ and set a new ``Exception`` object, or do nothing::
252252
)
253253
);
254254

255-
This indeed will skip all checks that Symfony processes on setting response status code.
256-
First check that Symfony does is fitting response status code.
257-
Symfony leaves set status code as it is if it belongs to one of group:
255+
If you do **not** set the ``X-Status-Code`` header, then Symfony uses the following
256+
logic to determine the status code:
258257

259-
:method:`Symfony\\Component\\HttpFoundation\\Response::isClientError`
258+
* If:method:`Symfony\\Component\\HttpFoundation\\Response::isClientError`,
259+
:method:`Symfony\\Component\\HttpFoundation\\Response::isServerError` or
260+
:method:`Symfony\\Component\\HttpFoundation\\Response::isRedirect` is true,
261+
then the status code on your ``Response`` object is used;
260262

261-
:method:`Symfony\\Component\\HttpFoundation\\Response::isServerError`
263+
* If the original exception implements
264+
:class:`Symfony\\Component\\HttpKernel\\Exception\\HttpExceptionInterface`,
265+
then ``getStatusCode()`` is called on the exception and used (the headers
266+
from ``getHeaders()`` are also added);
262267

263-
:method:`Symfony\\Component\\HttpFoundation\\Response::isRedirect`
264-
265-
If status code is different then Symfony checks instance of raised Exception if it is
266-
:class:`Symfony\\Component\\HttpKernel\\Exception\\HttpExceptionInterface` then its headers including status code are passed to response.
267-
Otherwise status code 500 is set to response.
268+
* If both of the above aren't true, then a 500 status code is used.
268269

269270
..seealso::
270271

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp