forked from reactphp/http
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServerRequest.php
More file actions
120 lines (102 loc) · 2.71 KB
/
Copy pathServerRequest.php
File metadata and controls
120 lines (102 loc) · 2.71 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?php
namespace React\Http;
use Psr\Http\Message\ServerRequestInterface;
use RingCentral\Psr7\Request;
/** @internal */
class ServerRequest extends Request implements ServerRequestInterface
{
private $attributes = array();
private $serverParams = array();
private $fileParams = array();
private $cookies = array();
private $queryParams = array();
private $parsedBody = null;
/**
* @param null|string $method HTTP method for the request.
* @param null|string|UriInterface $uri URI for the request.
* @param array $headers Headers for the message.
* @param string|resource|StreamInterface $body Message body.
* @param string $protocolVersion HTTP protocol version.
* @param array server-side parameters
*
* @throws InvalidArgumentException for an invalid URI
*/
public function __construct(
$method,
$uri,
array $headers = array(),
$body = null,
$protocolVersion = '1.1',
$serverParams = array()
) {
$this->serverParams = $serverParams;
parent::__construct($method, $uri, $headers, $body, $protocolVersion);
}
public function getServerParams()
{
return $this->serverParams;
}
public function getCookieParams()
{
return $this->cookies;
}
public function withCookieParams(array $cookies)
{
$new = clone $this;
$new->cookies = $cookies;
return $new;
}
public function getQueryParams()
{
return $this->queryParams;
}
public function withQueryParams(array $query)
{
$new = clone $this;
$new->queryParams = $query;
return $new;
}
public function getUploadedFiles()
{
return $this->fileParams;
}
public function withUploadedFiles(array $uploadedFiles)
{
$new = clone $this;
$new->fileParams = $uploadedFiles;
return $new;
}
public function getParsedBody()
{
return $this->parsedBody;
}
public function withParsedBody($data)
{
$new = clone $this;
$new->parsedBody = $data;
return $new;
}
public function getAttributes()
{
return $this->attributes;
}
public function getAttribute($name, $default = null)
{
if (!array_key_exists($name, $this->attributes)) {
return $default;
}
return $this->attributes[$name];
}
public function withAttribute($name, $value)
{
$new = clone $this;
$new->attributes[$name] = $value;
return $new;
}
public function withoutAttribute($name)
{
$new = clone $this;
unset($new->attributes[$name]);
return $new;
}
}