Skip to content

Commit

Permalink
Merge branch '6.4' into 7.0
Browse files Browse the repository at this point in the history
* 6.4:
  Update serializer.rst
  Update access_token.rst, removed letter
  [HttpClient] Fix how cookies are defined and sent
  • Loading branch information
javiereguiluz committed Jun 18, 2024
2 parents ed7e228 + 0402ace commit d4fe4cf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion components/serializer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ When serializing, you can set a callback to format a specific object property::

// all callback parameters are optional (you can omit the ones you don't use)
$dateCallback = function (object $innerObject, object $outerObject, string $attributeName, ?string $format = null, array $context = []): string {
return $innerObject instanceof \DateTime ? $innerObject->format(\DateTime::ISO8601) : '';
return $innerObject instanceof \DateTime ? $innerObject->format(\DateTime::ATOM) : '';
};

$defaultContext = [
Expand Down
13 changes: 9 additions & 4 deletions http_client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -679,17 +679,21 @@ cookies automatically.

You can either :ref:`send cookies with the BrowserKit component <component-browserkit-sending-cookies>`,
which integrates seamlessly with the HttpClient component, or manually setting
the ``Cookie`` HTTP header as follows::
`the Cookie HTTP request header`_ as follows::

use Symfony\Component\HttpClient\HttpClient;
use Symfony\Component\HttpFoundation\Cookie;

$client = HttpClient::create([
'headers' => [
'Cookie' => new Cookie('flavor', 'chocolate', strtotime('+1 day')),
// set one cookie as a name=value pair
'Cookie' => 'flavor=chocolate',

// you can also pass the cookie contents as a string
'Cookie' => 'flavor=chocolate; expires=Sat, 11 Feb 2023 12:18:13 GMT; Max-Age=86400; path=/'
// you can set multiple cookies at once separating them with a ;
'Cookie' => 'flavor=chocolate; size=medium',

// if needed, encode the cookie value to ensure that it contains valid characters
'Cookie' => sprintf("%s=%s", 'foo', rawurlencode('...')),
],
]);

Expand Down Expand Up @@ -2291,3 +2295,4 @@ you to do so, by yielding the exception from its body::
.. _`SSRF`: https://portswigger.net/web-security/ssrf
.. _`RFC 6570`: https://www.rfc-editor.org/rfc/rfc6570
.. _`HAR`: https://w3c.github.io/web-performance/specs/HAR/Overview.html
.. _`the Cookie HTTP request header`: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cookie
2 changes: 1 addition & 1 deletion security/access_token.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ This handler must implement

// and return a UserBadge object containing the user identifier from the found token
// (this is the same identifier used in Security configuration; it can be an email,
// a UUUID, a username, a database ID, etc.)
// a UUID, a username, a database ID, etc.)
return new UserBadge($accessToken->getUserId());
}
}
Expand Down

0 comments on commit d4fe4cf

Please sign in to comment.