19declare(strict_types=1);
23use Psr\Http\Message\ServerRequestInterface;
24use Psr\Http\Message\MessageInterface;
25use Psr\Http\Message\UriInterface;
26use Psr\Http\Message\RequestInterface;
27use Psr\Http\Message\StreamInterface;
31 private function request(): ServerRequestInterface
35 throw new \RuntimeException(
'Global DIC is not initialized; cannot access HTTP request.');
37 return $dic->http()->request();
42 return $this->
request()->getProtocolVersion();
47 return $this->
request()->withProtocolVersion($version);
52 return $this->
request()->getHeaders();
57 return $this->
request()->hasHeader($name);
62 return $this->
request()->getHeader($name);
67 return $this->
request()->getHeaderLine($name);
70 public function withHeader(
string $name, $value): MessageInterface
72 return $this->
request()->withHeader($name, $value);
77 return $this->
request()->withAddedHeader($name, $value);
82 return $this->
request()->withoutHeader($name);
85 public function getBody(): StreamInterface
87 return $this->
request()->getBody();
90 public function withBody(StreamInterface $body): MessageInterface
92 return $this->
request()->withBody($body);
97 return $this->
request()->getRequestTarget();
102 return $this->
request()->withRequestTarget($requestTarget);
107 return $this->
request()->getMethod();
112 return $this->
request()->withMethod($method);
117 return $this->
request()->getUri();
120 public function withUri(UriInterface $uri,
bool $preserveHost =
false): RequestInterface
122 return $this->
request()->withUri($uri, $preserveHost);
127 return $this->
request()->getServerParams();
132 return $this->
request()->getCookieParams();
137 return $this->
request()->withCookieParams($cookies);
142 return $this->
request()->getQueryParams();
147 return $this->
request()->withQueryParams($query);
152 return $this->
request()->getUploadedFiles();
157 return $this->
request()->withUploadedFiles($uploadedFiles);
162 return $this->
request()->getParsedBody();
172 return $this->
request()->getAttributes();
177 return $this->
request()->getAttribute($name, $default);
182 return $this->
request()->withAttribute($name, $value);
187 return $this->
request()->withoutAttribute($name);
withRequestTarget(string $requestTarget)
withoutAttribute(string $name)
withoutHeader(string $name)
getAttribute(string $name, $default=null)
withProtocolVersion(string $version)
withAttribute(string $name, $value)
withAddedHeader(string $name, $value)
withHeader(string $name, $value)
withUploadedFiles(array $uploadedFiles)
withCookieParams(array $cookies)
getHeaderLine(string $name)
withQueryParams(array $query)
withUri(UriInterface $uri, bool $preserveHost=false)
withMethod(string $method)
withBody(StreamInterface $body)