diff --git a/backend/lib/view/http/httphandle.php b/backend/lib/view/http/httphandle.php index 55e15f7..4b2eefd 100644 --- a/backend/lib/view/http/httphandle.php +++ b/backend/lib/view/http/httphandle.php @@ -21,7 +21,7 @@ abstract class HttpHandle { public $code; - public $headers = array(); + protected $headers = array(); protected static $codes = array( 100 => 'Continue', diff --git a/backend/lib/view/http/httprequest.php b/backend/lib/view/http/httprequest.php index 9975fd9..5aff302 100644 --- a/backend/lib/view/http/httprequest.php +++ b/backend/lib/view/http/httprequest.php @@ -29,6 +29,8 @@ class HttpRequest extends HttpHandle { public $files; public function __construct() { + $this->headers = apache_response_headers(); + $this->server = $_SERVER; $this->get = $_GET; $this->post = $_POST; @@ -41,5 +43,8 @@ class HttpRequest extends HttpHandle { unset($_COOKIE); unset($_FILES); } - + + public function getHeader($header) { + return $this->headers[$header]; + } } \ No newline at end of file diff --git a/backend/lib/view/http/httpresponse.php b/backend/lib/view/http/httpresponse.php index 231d575..a899b3b 100644 --- a/backend/lib/view/http/httpresponse.php +++ b/backend/lib/view/http/httpresponse.php @@ -24,6 +24,8 @@ class HttpResponse extends HttpHandle { public $code = 200; // default code (OK) public function __construct() { + $this->headers = apache_response_headers(); + ob_start(array($this, 'obCallback')); } @@ -41,5 +43,9 @@ class HttpResponse extends HttpHandle { } ob_end_flush(); } + + public function setHeader($header, $value) { + $this->headers[$header] = $value; + } } diff --git a/share/tools/tests.php b/share/tools/tests.php index 3b83a5f..ea3c718 100644 --- a/share/tools/tests.php +++ b/share/tools/tests.php @@ -23,11 +23,11 @@ include '../../backend/init.php'; $meter = current(Channel::getByFilter(array('id' => 1))); -$readings = $meter->getData(0, time()*1000, 'hour'); +$readings = $meter->getData(0, time()*1000); -echo '
' . ($i + 1) . ' | ' . date('l jS \of F Y h:i:s A', $reading['timestamp']/1000) . ' | ' . $reading['value'] . ' | ' . $reading['count'] . ' |
' . ($i + 1) . ' | ' . date('h:i:s', $reading['timestamp']/1000) . ' | ' . $reading['value'] . ' | ' . $reading['count'] . ' |