This commit is contained in:
2021-08-03 10:50:07 +08:00
parent 1dfd429211
commit 489ba0917f
+9 -3
View File
@@ -15,7 +15,6 @@ use HttpServer\Http\Formatter\HtmlFormatter;
use HttpServer\Http\Formatter\JsonFormatter; use HttpServer\Http\Formatter\JsonFormatter;
use HttpServer\Http\Formatter\XmlFormatter; use HttpServer\Http\Formatter\XmlFormatter;
use HttpServer\IInterface\IFormatter; use HttpServer\IInterface\IFormatter;
use JetBrains\PhpStorm\Pure;
use Snowflake\Core\Help; use Snowflake\Core\Help;
use Snowflake\Snowflake; use Snowflake\Snowflake;
use Swoole\Http\Response as SResponse; use Swoole\Http\Response as SResponse;
@@ -56,7 +55,15 @@ class Response extends HttpService
*/ */
public function setFormat($format): static public function setFormat($format): static
{ {
$this->format = $format; /** @var SResponse $response */
$response = Context::getContext(SResponse::class);
if ($format == self::HTML) {
$response->header('Content-Type', 'text/html;charset=utf-8');
} else if ($format == self::XML) {
$response->header('Content-Type', 'application/xml;charset=utf-8');
} else {
$response->header('Content-Type', 'application/json;charset=utf-8');
}
return $this; return $this;
} }
@@ -235,7 +242,6 @@ class Response extends HttpService
} }
/** /**
* @param $url * @param $url
* @param array $param * @param array $param