Jayson
Jayson

Reputation: 2193

why no set/getHeader in Symfony2's Request and Response class

although the headers attribute are public.

Upvotes: 5

Views: 4298

Answers (1)

igorw
igorw

Reputation: 28239

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\HeaderBag, the response headers are contained in a Symfony\Component\HttpFoundation\ResponseHeaderBag.

Upvotes: 14

Related Questions