This commit is contained in:
2023-08-16 01:01:47 +08:00
parent 6e7e20380f
commit 4461d23e0d
3 changed files with 43 additions and 17 deletions
+9
View File
@@ -4,6 +4,11 @@ declare(strict_types=1);
namespace Kiri\Router;
use Kiri\Server\Events\OnAfterRequest;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use ReflectionException;
/**
*
*/
@@ -16,6 +21,9 @@ class StreamResponse extends Response
/**
* @param object $response
* @return void
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws ReflectionException
*/
public function end(object $response): void
{
@@ -28,6 +36,7 @@ class StreamResponse extends Response
$response->write($body->read($this->limit));
}
$response->end();
event(new OnAfterRequest());
}
}
+9 -1
View File
@@ -5,7 +5,11 @@ namespace Kiri\Router;
use Exception;
use Kiri\Di\Interface\ResponseEmitterInterface;
use Kiri\Server\Events\OnAfterRequest;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\Http\Message\ResponseInterface;
use ReflectionException;
class SwooleHttpResponseEmitter implements ResponseEmitterInterface
@@ -16,7 +20,9 @@ class SwooleHttpResponseEmitter implements ResponseEmitterInterface
* @param Response $proxy
* @param object $response
* @return void
* @throws Exception
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws ReflectionException
*/
public function sender(ResponseInterface $proxy, object $response): void
{
@@ -24,6 +30,8 @@ class SwooleHttpResponseEmitter implements ResponseEmitterInterface
$this->writeParams($proxy, $response);
$proxy->end($response);
event(new OnAfterRequest());
}
+9
View File
@@ -3,7 +3,11 @@
namespace Kiri\Router;
use Kiri\Di\Interface\ResponseEmitterInterface;
use Kiri\Server\Events\OnAfterRequest;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\Http\Message\ResponseInterface;
use ReflectionException;
class SwowHttpResponseEmitter implements ResponseEmitterInterface
{
@@ -13,12 +17,17 @@ class SwowHttpResponseEmitter implements ResponseEmitterInterface
* @param Response $proxy
* @param object $response
* @return void
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws ReflectionException
*/
public function sender(ResponseInterface $proxy, object $response): void
{
// TODO: Implement sender() method.
$proxy->withHeader('Server', 'Swow');
$response->sendHttpResponse($proxy);
event(new OnAfterRequest());
}
}