Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

symfony

although the headers attribute are public.

like image 452
Jayson Avatar asked Apr 19 '11 17:04

Jayson


1 Answers

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.

like image 122
igorw Avatar answered Oct 11 '22 04:10

igorw