1 | <?php |
||
7 | class Response |
||
8 | { |
||
9 | /** |
||
10 | * @var \React\Http\Response |
||
11 | */ |
||
12 | private $httpResponse; |
||
13 | |||
14 | private $server; |
||
15 | private $version; |
||
16 | |||
17 | /** |
||
18 | * Status code of the response |
||
19 | * @var int |
||
20 | */ |
||
21 | private $status = 200; |
||
22 | |||
23 | /** |
||
24 | * Array of headers to send |
||
25 | * @var array |
||
26 | */ |
||
27 | private $headers = array(); |
||
28 | |||
29 | /** |
||
30 | * The content-length |
||
31 | * @var int |
||
32 | */ |
||
33 | private $contentLength = 0; |
||
34 | |||
35 | /** |
||
36 | * Data to send |
||
37 | * @var string |
||
38 | */ |
||
39 | private $data; |
||
40 | |||
41 | /** |
||
42 | * Check if headers are already sent |
||
43 | * @var bool |
||
44 | */ |
||
45 | private $headersSent = false; |
||
46 | |||
47 | /** |
||
48 | * Create a new Restify/Response object |
||
49 | * |
||
50 | * @param \React\Http\Response $response |
||
51 | * |
||
52 | */ |
||
53 | public function __construct(HttpResponse $response, $server = null, $version = null) |
||
59 | |||
60 | /** |
||
61 | * Add a header to the response |
||
62 | * |
||
63 | * @param string $name |
||
64 | * @param string $value |
||
65 | * |
||
66 | * @return Response |
||
67 | */ |
||
68 | public function addHeader($name, $value) |
||
74 | |||
75 | /** |
||
76 | * Set the status code of the response |
||
77 | * |
||
78 | * @param int $code |
||
79 | * |
||
80 | * @return Response |
||
81 | */ |
||
82 | public function setStatus($code) |
||
88 | |||
89 | /** |
||
90 | * is the response writable ? |
||
91 | * |
||
92 | * @return boolean |
||
93 | */ |
||
94 | public function isWritable() |
||
98 | |||
99 | /** |
||
100 | * Write a HTTP 100 (continue) header |
||
101 | */ |
||
102 | public function writeContinue() |
||
106 | |||
107 | /** |
||
108 | * Write data to the response |
||
109 | * |
||
110 | * @param string $data |
||
111 | */ |
||
112 | public function write($data) |
||
117 | |||
118 | /** |
||
119 | * Write json to the response |
||
120 | * |
||
121 | * @param mixed $data |
||
122 | */ |
||
123 | public function writeJson($data) |
||
130 | |||
131 | /** |
||
132 | * End the connexion |
||
133 | */ |
||
134 | public function end() |
||
140 | |||
141 | /** |
||
142 | * Close the connexion |
||
143 | */ |
||
144 | public function close() |
||
150 | |||
151 | /** |
||
152 | * Send all headers to the response |
||
153 | */ |
||
154 | public function sendHeaders() |
||
179 | } |
||
180 |