|
@@ -4,7 +4,7 @@
|
|
|
require_once(realpath(dirname(__DIR__).'/App/router.class.php'));
|
|
|
use \Juju\{App\Router, Events};
|
|
|
|
|
|
- class Response {
|
|
|
+ class Response implements \JsonSerializable {
|
|
|
use Events;
|
|
|
public $output = '';
|
|
|
public $body = '';
|
|
@@ -16,6 +16,13 @@
|
|
|
public function __toString(){
|
|
|
return $this->body;
|
|
|
}
|
|
|
+ public function jsonSerialize(){
|
|
|
+ return [
|
|
|
+ 'code'=> $this->code,
|
|
|
+ 'headers'=> $this->headers,
|
|
|
+ 'body'=> $this->body
|
|
|
+ ];
|
|
|
+ }
|
|
|
public function clear(){
|
|
|
if($this->open){
|
|
|
$this->fire('clear');
|
|
@@ -43,6 +50,8 @@
|
|
|
$this->fire('write', $chunk);
|
|
|
if($this->open){
|
|
|
$this->body .= $chunk;
|
|
|
+ $this->clear_header('Content-Length')
|
|
|
+ ->header('Content-Length', strlen($this->body));
|
|
|
}
|
|
|
return $this;
|
|
|
}
|