-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathRequest.php
More file actions
46 lines (37 loc) · 1.05 KB
/
Copy pathRequest.php
File metadata and controls
46 lines (37 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
declare(strict_types=1);
namespace Rancoud\Http\Message;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\StreamInterface;
use Psr\Http\Message\UriInterface;
class Request implements RequestInterface
{
use MessageTrait;
use RequestTrait;
/**
* @param resource|StreamInterface|string|null $body
*
* @throws \InvalidArgumentException
*/
public function __construct(
string $method,
string|UriInterface $uri,
array $headers = [],
mixed $body = null,
string $version = '1.1'
) {
$this->method = $this->filterMethod($method);
if (($uri instanceof UriInterface) === false) {
$uri = new Uri($uri);
}
$this->uri = $uri;
$this->setHeaders($headers);
if (!$this->hasHeader('Host')) {
$this->updateHostFromUri();
}
if ($body !== '' && $body !== null) {
$this->stream = Stream::create($body);
}
$this->protocol = $this->validateProtocolVersion($version);
}
}