eee
This commit is contained in:
@@ -20,6 +20,17 @@ interface AuthorizationInterface
|
||||
public function getUniqueId(): string|int;
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getNickname(): string;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAvatar(): string;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
|
||||
@@ -85,6 +85,15 @@ class ConstrictRequest extends Message implements RequestInterface, ServerReques
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getCookieParams(): array
|
||||
{
|
||||
return $this->cookieParams;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the message's request target.
|
||||
*
|
||||
@@ -568,7 +577,7 @@ class ConstrictRequest extends Message implements RequestInterface, ServerReques
|
||||
*/
|
||||
public static function builder(Request $request): static
|
||||
{
|
||||
$static = (new static())->withUri(new Uri($request));
|
||||
$static = (new static)->withUri(new Uri($request));
|
||||
$static->withHeaders($request->header ?? []);
|
||||
$static->withProtocolVersion($request->server['server_protocol']);
|
||||
$static->withCookieParams($request->cookie ?? []);
|
||||
|
||||
@@ -31,7 +31,13 @@ class Message extends Component implements MessageInterface
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private array $cookieParams = [];
|
||||
public array $cookieParams = [];
|
||||
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public array $data = [];
|
||||
|
||||
|
||||
/**
|
||||
@@ -45,23 +51,6 @@ class Message extends Component implements MessageInterface
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
@@ -120,37 +109,6 @@ class Message extends Component implements MessageInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves all message header values.
|
||||
*
|
||||
* The keys represent the header name as it will be sent over the wire, and
|
||||
* each value is an array of strings associated with the header.
|
||||
*
|
||||
* // Represent the headers as a string
|
||||
* foreach ($message->getHeaders() as $name => $values) {
|
||||
* echo $name . ": " . implode(", ", $values);
|
||||
* }
|
||||
*
|
||||
* // Emit headers iteratively:
|
||||
* foreach ($message->getHeaders() as $name => $values) {
|
||||
* foreach ($values as $value) {
|
||||
* header(sprintf('%s: %s', $name, $value), false);
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* While header names are not case-sensitive, getHeaders() will preserve the
|
||||
* exact case in which headers were originally specified.
|
||||
*
|
||||
* @return string[][] Returns an associative array of the message's headers. Each
|
||||
* key MUST be a header name, and each value MUST be an array of strings
|
||||
* for that header.
|
||||
*/
|
||||
public function getHeaders(): array
|
||||
{
|
||||
// TODO: Implement getHeaders() method.
|
||||
return $this->headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a header exists by the given case-insensitive name.
|
||||
*
|
||||
|
||||
@@ -813,6 +813,16 @@ class Request implements ServerRequestInterface
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function hasQuery(string $name): bool
|
||||
{
|
||||
return $this->getQueryParams()[$name] ?? false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param mixed|null $value
|
||||
|
||||
+1
-1
@@ -98,7 +98,7 @@ class Session
|
||||
*/
|
||||
private static function getSessionId(ServerRequestInterface $request): string
|
||||
{
|
||||
$cookies = $request->getCookieParams();
|
||||
$cookies = $request->cookieParams;
|
||||
|
||||
// 从 Cookie 中获取 Session ID
|
||||
if (isset($cookies[self::SESSION_NAME]) && !empty($cookies[self::SESSION_NAME])) {
|
||||
|
||||
Reference in New Issue
Block a user