forked from reactphp/http
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRequest.php
More file actions
133 lines (108 loc) · 2.47 KB
/
Request.php
File metadata and controls
133 lines (108 loc) · 2.47 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
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php
namespace React\Http;
use Evenement\EventEmitter;
use React\Stream\ReadableStreamInterface;
use React\Stream\WritableStreamInterface;
use React\Stream\Util;
class Request extends EventEmitter implements ReadableStreamInterface
{
private $readable = true;
private $method;
private $url;
private $query;
private $httpVersion;
private $headers;
private $body;
private $post = [];
private $files = [];
// metadata, implicitly added externally
public $remoteAddress;
public function __construct($method, $url, $query = array(), $httpVersion = '1.1', $headers = array(), $body = '')
{
$this->method = $method;
$this->url = $url;
$this->query = $query;
$this->httpVersion = $httpVersion;
$this->headers = new HeaderBag($headers);
$this->body = $body;
}
public function getMethod()
{
return $this->method;
}
public function getPath()
{
return $this->url->getPath();
}
public function getUrl()
{
return $this->url;
}
public function getQuery()
{
return $this->query;
}
public function getHttpVersion()
{
return $this->httpVersion;
}
public function getHeaders()
{
return $this->headers;
}
public function getBody()
{
return $this->body;
}
public function setBody($body)
{
$this->body = $body;
}
public function getFiles()
{
return $this->files;
}
public function setFiles($files)
{
$this->files = $files;
}
public function getPost()
{
return $this->post;
}
public function setPost($post)
{
$this->post = $post;
}
public function getRemoteAddress()
{
return $this->remoteAddress;
}
public function expectsContinue()
{
return isset($this->headers['Expect']) && '100-continue' === $this->headers['Expect'];
}
public function isReadable()
{
return $this->readable;
}
public function pause()
{
$this->emit('pause');
}
public function resume()
{
$this->emit('resume');
}
public function close()
{
$this->readable = false;
$this->emit('end');
$this->removeAllListeners();
}
public function pipe(WritableStreamInterface $dest, array $options = array())
{
Util::pipe($this, $dest, $options);
return $dest;
}
}