mirror of
https://github.com/SociallyDev/Spaces-API.git
synced 2025-07-30 11:39:10 -07:00
v2: Updates
* Simplifies & beautifies everything * Introduces a new Class system. * Errors are defaulted to AWS's handler. * New function names & more efficient handling. * Should fix a majority of the errors. Please read the README for more!
This commit is contained in:
parent
ad0726e41e
commit
e6d7753dc8
1095 changed files with 45088 additions and 2911 deletions
|
@ -36,6 +36,7 @@ class Request implements RequestInterface
|
|||
$body = null,
|
||||
$version = '1.1'
|
||||
) {
|
||||
$this->assertMethod($method);
|
||||
if (!($uri instanceof UriInterface)) {
|
||||
$uri = new Uri($uri);
|
||||
}
|
||||
|
@ -45,7 +46,7 @@ class Request implements RequestInterface
|
|||
$this->setHeaders($headers);
|
||||
$this->protocol = $version;
|
||||
|
||||
if (!$this->hasHeader('Host')) {
|
||||
if (!isset($this->headerNames['host'])) {
|
||||
$this->updateHostFromUri();
|
||||
}
|
||||
|
||||
|
@ -91,6 +92,7 @@ class Request implements RequestInterface
|
|||
|
||||
public function withMethod($method)
|
||||
{
|
||||
$this->assertMethod($method);
|
||||
$new = clone $this;
|
||||
$new->method = strtoupper($method);
|
||||
return $new;
|
||||
|
@ -110,7 +112,7 @@ class Request implements RequestInterface
|
|||
$new = clone $this;
|
||||
$new->uri = $uri;
|
||||
|
||||
if (!$preserveHost) {
|
||||
if (!$preserveHost || !isset($this->headerNames['host'])) {
|
||||
$new->updateHostFromUri();
|
||||
}
|
||||
|
||||
|
@ -139,4 +141,11 @@ class Request implements RequestInterface
|
|||
// See: http://tools.ietf.org/html/rfc7230#section-5.4
|
||||
$this->headers = [$header => [$host]] + $this->headers;
|
||||
}
|
||||
|
||||
private function assertMethod($method)
|
||||
{
|
||||
if (!is_string($method) || $method === '') {
|
||||
throw new \InvalidArgumentException('Method must be a non-empty string.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue