改名
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,7 +86,7 @@ class Response extends HttpService
|
|||||||
|
|
||||||
/** @var SResponse $response */
|
/** @var SResponse $response */
|
||||||
$response = Context::getContext(SResponse::class);
|
$response = Context::getContext(SResponse::class);
|
||||||
$response->header('Content-Type','text/html;charset=utf-8');
|
$response->header('Content-Type', 'text/html;charset=utf-8');
|
||||||
|
|
||||||
return (string)$content;
|
return (string)$content;
|
||||||
}
|
}
|
||||||
@@ -95,7 +102,7 @@ class Response extends HttpService
|
|||||||
|
|
||||||
/** @var SResponse $response */
|
/** @var SResponse $response */
|
||||||
$response = Context::getContext(SResponse::class);
|
$response = Context::getContext(SResponse::class);
|
||||||
$response->header('Content-Type','application/json;charset=utf-8');
|
$response->header('Content-Type', 'application/json;charset=utf-8');
|
||||||
|
|
||||||
return json_encode($content, JSON_UNESCAPED_UNICODE);
|
return json_encode($content, JSON_UNESCAPED_UNICODE);
|
||||||
}
|
}
|
||||||
@@ -111,7 +118,7 @@ class Response extends HttpService
|
|||||||
|
|
||||||
/** @var SResponse $response */
|
/** @var SResponse $response */
|
||||||
$response = Context::getContext(SResponse::class);
|
$response = Context::getContext(SResponse::class);
|
||||||
$response->header('Content-Type','application/xml;charset=utf-8');
|
$response->header('Content-Type', 'application/xml;charset=utf-8');
|
||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
@@ -235,7 +242,6 @@ class Response extends HttpService
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $url
|
* @param $url
|
||||||
* @param array $param
|
* @param array $param
|
||||||
|
|||||||
Reference in New Issue
Block a user