This commit is contained in:
2023-04-16 03:30:06 +08:00
parent d32768064a
commit b16348927a
4 changed files with 50 additions and 63 deletions
+1 -40
View File
@@ -29,7 +29,7 @@ class ConstrictRequest extends Message implements RequestInterface, ServerReques
private array $files = [];
private array $queryParams = [];
private array $cookieParams = [];
private array $serverParams = [];
@@ -211,45 +211,6 @@ class ConstrictRequest extends Message implements RequestInterface, ServerReques
return $this->serverParams = [];
}
/**
* Retrieve cookies.
*
* Retrieves cookies sent by the client to the server.
*
* The data MUST be compatible with the structure of the $_COOKIE
* superglobal.
*
* @return array
*/
public function getCookieParams(): array
{
// TODO: Implement getCookieParams() method.
return $this->cookieParams;
}
/**
* Return an instance with the specified cookies.
*
* The data IS NOT REQUIRED to come from the $_COOKIE superglobal, but MUST
* be compatible with the structure of $_COOKIE. Typically, this data will
* be injected at instantiation.
*
* This method MUST NOT update the related Cookie header of the request
* instance, nor related values in the server params.
*
* This method MUST be implemented in such a way as to retain the
* immutability of the message, and MUST return an instance that has the
* updated cookie values.
*
* @param array $cookies Array of key/value pairs representing cookies.
* @return static
*/
public function withCookieParams(array $cookies): static
{
// TODO: Implement withCookieParams() method.
$this->cookieParams = $cookies;
return $this;
}
/**
* Return an instance with the specified cookies.
-22
View File
@@ -14,7 +14,6 @@ class ConstrictResponse extends Message implements ResponseInterface
private string $reasonPhrase;
private array $cookieParams;
/**
@@ -90,27 +89,6 @@ class ConstrictResponse extends Message implements ResponseInterface
/**
* @param array $cookies
* @return ResponseInterface
*/
public function withCookieParams(array $cookies): static
{
$this->cookieParams = $cookies;
return $this;
}
/**
* @return array
*/
public function getCookieParams(): array
{
return $this->cookieParams;
}
/**
* @param object $response
* @return void
+48
View File
@@ -27,6 +27,54 @@ class Message implements MessageInterface
*/
private StreamInterface $stream;
/**
* @var array
*/
private array $cookieParams = [];
/**
* Retrieve cookies.
*
* Retrieves cookies sent by the client to the server.
*
* The data MUST be compatible with the structure of the $_COOKIE
* superglobal.
*
* @return array
*/
public function getCookieParams(): array
{
// TODO: Implement getCookieParams() method.
return $this->cookieParams;
}
/**
* Return an instance with the specified cookies.
*
* The data IS NOT REQUIRED to come from the $_COOKIE superglobal, but MUST
* be compatible with the structure of $_COOKIE. Typically, this data will
* be injected at instantiation.
*
* This method MUST NOT update the related Cookie header of the request
* instance, nor related values in the server params.
*
* This method MUST be implemented in such a way as to retain the
* immutability of the message, and MUST return an instance that has the
* updated cookie values.
*
* @param array $cookies Array of key/value pairs representing cookies.
* @return static
*/
public function withCookieParams(array $cookies): static
{
// TODO: Implement withCookieParams() method.
$this->cookieParams = $cookies;
return $this;
}
/**
* Retrieves the HTTP protocol version as a string.
+1 -1
View File
@@ -114,7 +114,7 @@ class Server implements OnRequestInterface
/** @var ConstrictResponse $PsrResponse */
$PsrResponse = Context::set(ResponseInterface::class, new ConstrictResponse());
$PsrResponse->withContentType($response->contentType)->withCookieParams($cookie);
$PsrResponse->withContentType($response->contentType);
$serverRequest = (new ConstrictRequest())->withDataHeaders($request->getData())
->withUri(Uri::parse($request))