111
This commit is contained in:
+59
-50
@@ -13,7 +13,7 @@ use Psr\Http\Message\UriInterface;
|
||||
abstract class Request implements RequestInterface
|
||||
{
|
||||
|
||||
use Message;
|
||||
use Message;
|
||||
|
||||
|
||||
/**
|
||||
@@ -28,63 +28,72 @@ abstract class Request implements RequestInterface
|
||||
protected string $method;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRequestTarget(): string
|
||||
{
|
||||
throw new BadMethodCallException('Not Accomplish Method.');
|
||||
}
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRequestTarget(): string
|
||||
{
|
||||
throw new BadMethodCallException('Not Accomplish Method.');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param mixed $requestTarget
|
||||
* @return static
|
||||
*/
|
||||
public function withRequestTarget($requestTarget): static
|
||||
{
|
||||
throw new BadMethodCallException('Not Accomplish Method.');
|
||||
}
|
||||
/**
|
||||
* @param mixed $requestTarget
|
||||
* @return static
|
||||
*/
|
||||
public function withRequestTarget($requestTarget): static
|
||||
{
|
||||
throw new BadMethodCallException('Not Accomplish Method.');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMethod(): string
|
||||
{
|
||||
return $this->method;
|
||||
}
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMethod(): string
|
||||
{
|
||||
return $this->method;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $method
|
||||
* @return RequestInterface
|
||||
*/
|
||||
public function withMethod($method): RequestInterface
|
||||
{
|
||||
$this->method = $method;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* @param string $method
|
||||
* @return RequestInterface
|
||||
*/
|
||||
public function withMethod($method): RequestInterface
|
||||
{
|
||||
$this->method = $method;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return UriInterface
|
||||
*/
|
||||
public function getUri(): UriInterface
|
||||
{
|
||||
return $this->uriInterface;
|
||||
}
|
||||
/**
|
||||
* @param string $method
|
||||
* @return bool
|
||||
*/
|
||||
public function isMethod(string $method): bool
|
||||
{
|
||||
return $this->method == $method;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param UriInterface $uri
|
||||
* @param false $preserveHost
|
||||
* @return $this|Request
|
||||
*/
|
||||
public function withUri(UriInterface $uri, $preserveHost = false): RequestInterface
|
||||
{
|
||||
$this->uriInterface = $uri;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* @return UriInterface
|
||||
*/
|
||||
public function getUri(): UriInterface
|
||||
{
|
||||
return $this->uriInterface;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param UriInterface $uri
|
||||
* @param false $preserveHost
|
||||
* @return $this|Request
|
||||
*/
|
||||
public function withUri(UriInterface $uri, $preserveHost = false): RequestInterface
|
||||
{
|
||||
$this->uriInterface = $uri;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,8 @@
|
||||
namespace Protocol\Message;
|
||||
|
||||
use Http\Context\Context;
|
||||
use Kiri\Core\Xml;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
use Psr\Http\Message\UploadedFileInterface;
|
||||
|
||||
|
||||
/**
|
||||
@@ -98,42 +94,6 @@ class ServerRequest extends Request implements ServerRequestInterface
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param mixed|null $default
|
||||
* @return mixed
|
||||
*/
|
||||
public function post(string $name, mixed $default = null): mixed
|
||||
{
|
||||
return $this->parsedBody[$name] ?? $default;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string|null $default
|
||||
* @return string|null
|
||||
*/
|
||||
public function query(string $name, ?string $default = null): ?string
|
||||
{
|
||||
return $this->queryParams[$name] ?? $default;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return \Psr\Http\Message\UploadedFileInterface|null
|
||||
*/
|
||||
public function file(string $name): ?UploadedFileInterface
|
||||
{
|
||||
if (isset($this->parsedBody[$name])) {
|
||||
$files = $this->parsedBody[$name];
|
||||
return new Uploaded($files['tmp_name'], $files['name'], $files['type'], $files['size'], $files['error']);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return null|array
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user