Why set / getHeader in class Symfony2 Request and Response

although the headers attribute is publicly available.

+5
source share
1 answer

Because they are public. Just access them through the property directly:

$request->headers->get('Content-Type');

The request header collection is an instance of Symfony\Component\HttpFoundation\HeaderBagthe response headers contained in Symfony\Component\HttpFoundation\ResponseHeaderBag.

+14
source

All Articles