Commit 5b6a48a63b762086eeaeace691f6ffde7b12b947

  • avatar
  • p4bl0 <pablo.rauzy @gm…l.com>
  • Mon Aug 17 18:38:04 CEST 2009
  • Tree SHA1: 1c21384
  • Parent SHA1: 2709403 (change to use default view by default in REST controllers instead of the action name as in normal controllers)
  • raw diff | raw patch
added two methods to Belokan_Request to retrieve http headers as an array and http body as a string
Request.php
(21 / 1)
  
2020 $_method,
2121 $_xhr,
2222 $_reload,
23 $_fromElsewhere;
23 $_fromElsewhere,
24 $_headers,
25 $_body;
2426
2527 public static function getInstance ()
2628 {
6464 $this->_xhr = null;
6565 $this->_reload = null;
6666 $this->_fromElsewhere = null;
67 $this->_headers = null;
68 $this->_body = null;
6769 }
6870
6971 public function getController ()
184184 $this->_fromElsewhere = (!isset($_SERVER['HTTP_REFERER']) ||
185185 strpos($_SERVER['HTTP_REFERER'], 'http://'.$_SERVER['HTTP_HOST']) === false);
186186 return $this->_fromElsewhere;
187 }
188
189 public function getHeaders ()
190 {
191 if ($this->_headers === null)
192 foreach ($_SERVER as $k => $v)
193 if (substr($k, 0, 5) == 'HTTP_')
194 $this->_headers[substr($k, 5)] = $v;
195 return $this->_headers;
196 }
197
198 public function getBody ()
199 {
200 if ($this->_body === null)
201 $this->_body = file_get_contents('php://input');
202 return $this->_body;
187203 }
188204
189205}