This commit is contained in:
as2252258@163.com
2021-08-28 01:40:33 +08:00
parent fc634c94ed
commit 30e639fe69
2 changed files with 22 additions and 2 deletions
+9
View File
@@ -23,6 +23,15 @@ class Response implements ResponseInterface, \Server\ResponseInterface
const CONTENT_TYPE_XML = 'application/xml;charset=utf-8'; const CONTENT_TYPE_XML = 'application/xml;charset=utf-8';
/**
*
*/
public function __construct()
{
$this->stream = new Stream('');
}
/** /**
* @param string $type * @param string $type
* @return $this * @return $this
+13 -2
View File
@@ -133,13 +133,25 @@ class Stream implements StreamInterface
*/ */
public function write($string): int 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->body .= $string;
$this->size = strlen($this->body); $this->size = strlen($this->body);
return $this->size; return $this->size;
} }
/** /**
* @return bool * @return bool
*/ */
@@ -155,7 +167,6 @@ class Stream implements StreamInterface
*/ */
public function read($length): string public function read($length): string
{ {
// TODO: Implement read() method.
return substr($this->body, 0, $length); return substr($this->body, 0, $length);
} }