改名
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Server\Constrict;
|
||||
|
||||
use Exception;
|
||||
use Http\Context\Formatter\FileFormatter;
|
||||
use Kiri\Exception\NotFindClassException;
|
||||
use ReflectionException;
|
||||
use Server\ResponseInterface;
|
||||
use Swoole\Server;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class ResponseEmitter implements Emitter
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param \Swoole\Http\Response|\Swoole\Http2\Response $response
|
||||
* @param ResponseInterface $emitter
|
||||
* @throws NotFindClassException
|
||||
* @throws ReflectionException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function sender(mixed $response, ResponseInterface $emitter): void
|
||||
{
|
||||
$content = $emitter->configure($response)->getContent();
|
||||
if ($content instanceof FileFormatter) {
|
||||
di(DownloadEmitter::class)->sender($response, $emitter);
|
||||
return;
|
||||
}
|
||||
$response->header('Content-Type', $emitter->getResponseFormat());
|
||||
$response->end($content->getData());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user