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

Commit830b366

Browse files
committed
Documented the default values of Accept headers
1 parent5bb7c53 commit830b366

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

‎components/http_foundation.rst‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,19 @@ If you need to get full access to parsed data from ``Accept``, ``Accept-Language
269269
$accepts = AcceptHeader::fromString($request->headers->get('Accept'))
270270
->all();
271271

272+
The default values that can be optionally included in the ``Accept-*`` headers
273+
are also supported::
274+
275+
$acceptHeader = 'text/plain;q=0.5, text/html, text/*;q=0.8, */*;q=0.3';
276+
$accept = AcceptHeader::fromString($acceptHeader);
277+
278+
$quality = $accept->get('text/xml')->getQuality(); // $quality = 0.8
279+
$quality = $accept->get('application/xml')->getQuality(); // $quality = 0.3
280+
281+
..versionadded::4.1
282+
The support of default values in the ``Accept-*`` headers was introduced in
283+
Symfony 4.1.
284+
272285
Accessing other Data
273286
~~~~~~~~~~~~~~~~~~~~
274287

@@ -403,7 +416,7 @@ of methods to manipulate the HTTP headers related to the cache:
403416
..note::
404417

405418
The methods:method:`Symfony\\Component\\HttpFoundation\\Response::setExpires`,
406-
:method:`Symfony\\Component\\HttpFoundation\\Response::setLastModified` and
419+
:method:`Symfony\\Component\\HttpFoundation\\Response::setLastModified` and
407420
:method:`Symfony\\Component\\HttpFoundation\\Response::setDate` accept any
408421
object that implements ``\DateTimeInterface``, including immutable date objects.
409422

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp