Skip to content

Commit bfc455a

Browse files
committed
minor #9292 Documented the default values of Accept headers (javiereguiluz)
This PR was merged into the master branch. Discussion ---------- Documented the default values of Accept headers This fixes #9290. Commits ------- 830b366 Documented the default values of Accept headers
2 parents 5bb7c53 + 830b366 commit bfc455a

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)