1

I'm trying to get header content from a json post request. But I can't seem to find a method for it in the requesthandler...

print_r($this->request); doesn't show anything useful. I've tried

$this->request['head'];

$this->request['header'];

$this->request->getHeaders;

None of which work

Mark
  • 2,423
  • 4
  • 24
  • 40

2 Answers2

6

You can access the headers using:

 $this->request->header('User-Agent');

http://book.cakephp.org/2.0/en/controllers/request-response.html#CakeRequest::header

cornelb
  • 6,046
  • 3
  • 19
  • 30
0

CakePHP 2 doesn't have

$this->request->headers()

or something like that.

You can use the PHP function getallheaders() instead.