@@ -706,31 +706,37 @@ Session
706
706
707
707
The session information is in its own document: :doc: `/components/http_foundation/sessions `.
708
708
709
- Safe content preference - RFC 8674
710
- ----------------------------------
709
+ Safe Content Preference
710
+ -----------------------
711
711
712
- `RFC 8674 `_ (not yet an IETF standard) defines a way for user agents to ask for "safe"
713
- content to a server. Symfony offers 2 methods to interact with this preference:
712
+ Some web sites have a "safe" mode to assist those who don't want to be exposed
713
+ to content to which they might object. The `RFC 8674 `_ specification defines a
714
+ way for user agents to ask for safe content to a server.
715
+
716
+ The specification does not define what content might be considered objectionable,
717
+ so the concept of "safe" is not precisely defined. Rather, the term is interpreted
718
+ by the server and within the scope of each web site that chooses to act upon this information.
719
+
720
+ Symfony offers two methods to interact with this preference:
714
721
715
722
* :method: `Symfony\\ Component\\ HttpFoundation\\ Request::preferSafeContent `;
716
723
* :method: `Symfony\\ Component\\ HttpFoundation\\ Response::setContentSafe `;
717
724
718
- When the user agent prefers "safe" content, you can detect it and send it a more appropriate
719
- reponse::
725
+ .. versionadded :: 5.1
726
+
727
+ The ``preferSafeContent() `` and ``setContentSafe() `` methods were introduced
728
+ in Symfony 5.1.
729
+
730
+ The following example shows how to detect if the user agent prefers "safe" content::
720
731
721
732
if ($request->preferSafeContent()) {
722
733
$response = new Response($alternativeContent);
723
- $response->setContentSafe(); // Inform the user we respected their preferences
724
-
734
+ // this informs the user we respected their preferences
735
+ $response->setContentSafe();
736
+
725
737
return $response;
726
738
}
727
739
728
- .. note ::
729
-
730
- The RFC 8674 does not define a precise semantic for "safe". Rather, the term is interpreted
731
- by the server and within the scope of each web site that chooses to act upon this information.
732
-
733
-
734
740
Learn More
735
741
----------
736
742
0 commit comments