改名
This commit is contained in:
@@ -177,10 +177,7 @@ trait Message
|
|||||||
*/
|
*/
|
||||||
private function addRequestHeader($key, $value)
|
private function addRequestHeader($key, $value)
|
||||||
{
|
{
|
||||||
$this->headers[$key] = [];
|
$this->headers[$key] = [$value];
|
||||||
foreach (explode(';', $value) as $item) {
|
|
||||||
$this->headers[$key][] = $item;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace Server\Message;
|
namespace Server\Message;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use JetBrains\PhpStorm\Pure;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
|
||||||
|
|
||||||
@@ -26,23 +28,24 @@ class Response implements ResponseInterface, \Server\ResponseInterface
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
#[Pure] public function __construct()
|
||||||
{
|
{
|
||||||
$this->stream = new Stream('');
|
$this->stream = new Stream('');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
* @throws Exception
|
||||||
|
*/
|
||||||
public function withContentType(string $type): static
|
public function withContentType(string $type): static
|
||||||
{
|
{
|
||||||
if (!in_array($type, [
|
if (!in_array($type, [
|
||||||
Response::CONTENT_TYPE_HTML, Response::CONTENT_TYPE_JSON,
|
Response::CONTENT_TYPE_HTML, Response::CONTENT_TYPE_JSON,
|
||||||
Response::CONTENT_TYPE_STREAM, Response::CONTENT_TYPE_XML
|
Response::CONTENT_TYPE_STREAM, Response::CONTENT_TYPE_XML
|
||||||
])) {
|
])) {
|
||||||
throw new \Exception('Wrong content type.');
|
throw new Exception('Wrong content type.');
|
||||||
}
|
}
|
||||||
return $this->withHeader('Content-Type', $type);
|
return $this->withHeader('Content-Type', $type);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user