eee
This commit is contained in:
@@ -7,6 +7,7 @@ use Kiri\Core\Help;
|
|||||||
use Kiri\Router\ContentType;
|
use Kiri\Router\ContentType;
|
||||||
use Kiri\Router\StreamResponse;
|
use Kiri\Router\StreamResponse;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
use Swoole\Http\Response;
|
||||||
|
|
||||||
|
|
||||||
class ConstrictResponse extends Message implements ResponseInterface
|
class ConstrictResponse extends Message implements ResponseInterface
|
||||||
@@ -19,11 +20,18 @@ class ConstrictResponse extends Message implements ResponseInterface
|
|||||||
private string $reasonPhrase;
|
private string $reasonPhrase;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array|mixed
|
||||||
|
*/
|
||||||
|
public array $headers = [];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ContentType|null $contentType
|
* @param ContentType|null $contentType
|
||||||
*/
|
*/
|
||||||
public function __construct(?ContentType $contentType = null)
|
public function __construct(?ContentType $contentType = null)
|
||||||
{
|
{
|
||||||
|
$this->headers = \config('response.headers', $this->headers);
|
||||||
if ($contentType != null) {
|
if ($contentType != null) {
|
||||||
$this->withHeader('Content-Type', $contentType->toString());
|
$this->withHeader('Content-Type', $contentType->toString());
|
||||||
}
|
}
|
||||||
@@ -207,6 +215,10 @@ class ConstrictResponse extends Message implements ResponseInterface
|
|||||||
*/
|
*/
|
||||||
public function end(object $response): void
|
public function end(object $response): void
|
||||||
{
|
{
|
||||||
|
/** @var Response $response */
|
||||||
|
if (count($this->headers) > 0) foreach ($this->headers as $key => $header) {
|
||||||
|
$response->header($key, $header);
|
||||||
|
}
|
||||||
$response->end($this->stream->getContents());
|
$response->end($this->stream->getContents());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user