From 830b3661c0f5b0232aba67f73eccb55e87aa4b26 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sun, 18 Feb 2018 13:10:08 +0100 Subject: [PATCH] Documented the default values of Accept headers --- components/http_foundation.rst | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/components/http_foundation.rst b/components/http_foundation.rst index 86eb62c0e2d..6bc3409c96a 100644 --- a/components/http_foundation.rst +++ b/components/http_foundation.rst @@ -269,6 +269,19 @@ If you need to get full access to parsed data from ``Accept``, ``Accept-Language $accepts = AcceptHeader::fromString($request->headers->get('Accept')) ->all(); +The default values that can be optionally included in the ``Accept-*`` headers +are also supported:: + + $acceptHeader = 'text/plain;q=0.5, text/html, text/*;q=0.8, */*;q=0.3'; + $accept = AcceptHeader::fromString($acceptHeader); + + $quality = $accept->get('text/xml')->getQuality(); // $quality = 0.8 + $quality = $accept->get('application/xml')->getQuality(); // $quality = 0.3 + +.. versionadded:: 4.1 + The support of default values in the ``Accept-*`` headers was introduced in + Symfony 4.1. + Accessing other Data ~~~~~~~~~~~~~~~~~~~~ @@ -403,7 +416,7 @@ of methods to manipulate the HTTP headers related to the cache: .. note:: The methods :method:`Symfony\\Component\\HttpFoundation\\Response::setExpires`, - :method:`Symfony\\Component\\HttpFoundation\\Response::setLastModified` and + :method:`Symfony\\Component\\HttpFoundation\\Response::setLastModified` and :method:`Symfony\\Component\\HttpFoundation\\Response::setDate` accept any object that implements ``\DateTimeInterface``, including immutable date objects.