diff --git a/http-server/Message/Response.php b/http-server/Message/Response.php index aaf244fc..9806bed3 100644 --- a/http-server/Message/Response.php +++ b/http-server/Message/Response.php @@ -23,6 +23,15 @@ class Response implements ResponseInterface, \Server\ResponseInterface const CONTENT_TYPE_XML = 'application/xml;charset=utf-8'; + /** + * + */ + public function __construct() + { + $this->stream = new Stream(''); + } + + /** * @param string $type * @return $this diff --git a/http-server/Message/Stream.php b/http-server/Message/Stream.php index 175a9d08..89db7fe2 100644 --- a/http-server/Message/Stream.php +++ b/http-server/Message/Stream.php @@ -133,13 +133,25 @@ class Stream implements StreamInterface */ public function write($string): int { - // TODO: Implement write() method. + $this->body = $string; + $this->size = strlen($this->body); + return $this->size; + } + + + /** + * @param string $string + * @return int + */ + public function append($string): int + { $this->body .= $string; $this->size = strlen($this->body); return $this->size; } + /** * @return bool */ @@ -155,7 +167,6 @@ class Stream implements StreamInterface */ public function read($length): string { - // TODO: Implement read() method. return substr($this->body, 0, $length); }