-
-
Notifications
You must be signed in to change notification settings - Fork 90
Expand file tree
/
Copy pathIResponse.php
More file actions
237 lines (214 loc) · 5.75 KB
/
Copy pathIResponse.php
File metadata and controls
237 lines (214 loc) · 5.75 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
<?php
/**
* This file is part of the Nette Framework (https://nette.org)
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
*/
declare(strict_types=1);
namespace Nette\Http;
/**
* HTTP response interface.
*/
interface IResponse
{
/** HTTP 1.1 response code */
public const
S100_CONTINUE = 100,
S101_SWITCHING_PROTOCOLS = 101,
S102_PROCESSING = 102,
S200_OK = 200,
S201_CREATED = 201,
S202_ACCEPTED = 202,
S203_NON_AUTHORITATIVE_INFORMATION = 203,
S204_NO_CONTENT = 204,
S205_RESET_CONTENT = 205,
S206_PARTIAL_CONTENT = 206,
S207_MULTI_STATUS = 207,
S208_ALREADY_REPORTED = 208,
S226_IM_USED = 226,
S300_MULTIPLE_CHOICES = 300,
S301_MOVED_PERMANENTLY = 301,
S302_FOUND = 302,
S303_SEE_OTHER = 303,
S303_POST_GET = 303,
S304_NOT_MODIFIED = 304,
S305_USE_PROXY = 305,
S307_TEMPORARY_REDIRECT = 307,
S308_PERMANENT_REDIRECT = 308,
S400_BAD_REQUEST = 400,
S401_UNAUTHORIZED = 401,
S402_PAYMENT_REQUIRED = 402,
S403_FORBIDDEN = 403,
S404_NOT_FOUND = 404,
S405_METHOD_NOT_ALLOWED = 405,
S406_NOT_ACCEPTABLE = 406,
S407_PROXY_AUTHENTICATION_REQUIRED = 407,
S408_REQUEST_TIMEOUT = 408,
S409_CONFLICT = 409,
S410_GONE = 410,
S411_LENGTH_REQUIRED = 411,
S412_PRECONDITION_FAILED = 412,
S413_REQUEST_ENTITY_TOO_LARGE = 413,
S414_REQUEST_URI_TOO_LONG = 414,
S415_UNSUPPORTED_MEDIA_TYPE = 415,
S416_REQUESTED_RANGE_NOT_SATISFIABLE = 416,
S417_EXPECTATION_FAILED = 417,
S421_MISDIRECTED_REQUEST = 421,
S422_UNPROCESSABLE_ENTITY = 422,
S423_LOCKED = 423,
S424_FAILED_DEPENDENCY = 424,
S426_UPGRADE_REQUIRED = 426,
S428_PRECONDITION_REQUIRED = 428,
S429_TOO_MANY_REQUESTS = 429,
S431_REQUEST_HEADER_FIELDS_TOO_LARGE = 431,
S451_UNAVAILABLE_FOR_LEGAL_REASONS = 451,
S500_INTERNAL_SERVER_ERROR = 500,
S501_NOT_IMPLEMENTED = 501,
S502_BAD_GATEWAY = 502,
S503_SERVICE_UNAVAILABLE = 503,
S504_GATEWAY_TIMEOUT = 504,
S505_HTTP_VERSION_NOT_SUPPORTED = 505,
S506_VARIANT_ALSO_NEGOTIATES = 506,
S507_INSUFFICIENT_STORAGE = 507,
S508_LOOP_DETECTED = 508,
S510_NOT_EXTENDED = 510,
S511_NETWORK_AUTHENTICATION_REQUIRED = 511;
public const REASON_PHRASES = [
100 => 'Continue',
101 => 'Switching Protocols',
102 => 'Processing',
200 => 'OK',
201 => 'Created',
202 => 'Accepted',
203 => 'Non-Authoritative Information',
204 => 'No Content',
205 => 'Reset Content',
206 => 'Partial Content',
207 => 'Multi-status',
208 => 'Already Reported',
226 => 'IM Used',
300 => 'Multiple Choices',
301 => 'Moved Permanently',
302 => 'Found',
303 => 'See Other',
304 => 'Not Modified',
305 => 'Use Proxy',
307 => 'Temporary Redirect',
308 => 'Permanent Redirect',
400 => 'Bad Request',
401 => 'Unauthorized',
402 => 'Payment Required',
403 => 'Forbidden',
404 => 'Not Found',
405 => 'Method Not Allowed',
406 => 'Not Acceptable',
407 => 'Proxy Authentication Required',
408 => 'Request Time-out',
409 => 'Conflict',
410 => 'Gone',
411 => 'Length Required',
412 => 'Precondition Failed',
413 => 'Request Entity Too Large',
414 => 'Request-URI Too Large',
415 => 'Unsupported Media Type',
416 => 'Requested range not satisfiable',
417 => 'Expectation Failed',
421 => 'Misdirected Request',
422 => 'Unprocessable Entity',
423 => 'Locked',
424 => 'Failed Dependency',
426 => 'Upgrade Required',
428 => 'Precondition Required',
429 => 'Too Many Requests',
431 => 'Request Header Fields Too Large',
451 => 'Unavailable For Legal Reasons',
500 => 'Internal Server Error',
501 => 'Not Implemented',
502 => 'Bad Gateway',
503 => 'Service Unavailable',
504 => 'Gateway Time-out',
505 => 'HTTP Version not supported',
506 => 'Variant Also Negotiates',
507 => 'Insufficient Storage',
508 => 'Loop Detected',
510 => 'Not Extended',
511 => 'Network Authentication Required',
];
/**
* Sets HTTP protocol version.
* @return static
*/
function setProtocolVersion(string $version);
/**
* Returns HTTP protocol version.
*/
function getProtocolVersion(): string;
/**
* Sets HTTP response code.
* @return static
*/
function setCode(int $code, string $reason = null);
/**
* Returns HTTP response code.
*/
function getCode(): int;
/**
* Returns HTTP reason phrase.
*/
function getReasonPhrase(): string;
/**
* Sends a HTTP header and replaces a previous one.
* @return static
*/
function setHeader(string $name, string $value);
/**
* Adds HTTP header.
* @return static
*/
function addHeader(string $name, string $value);
/**
* @return static
*/
function deleteHeader(string $name);
/**
* Sends a Content-type HTTP header.
* @return static
*/
function setContentType(string $type, string $charset = null);
/**
* Redirects to a new URL.
*/
function redirect(string $url, int $code = self::S302_FOUND): void;
/**
* Sets the time (like '20 minutes') before a page cached on a browser expires, null means "must-revalidate".
* @return static
*/
function setExpiration(?string $expire);
/**
* Returns value of an HTTP header.
*/
function getHeader(string $header): ?string;
/**
* Returns a associative array of headers to sent.
* @return string[][]
*/
function getHeaders(): array;
/**
* Sends a cookie.
* @param string|int|\DateTimeInterface $expire time, value 0 means "until the browser is closed"
* @return static
*/
function setCookie(string $name, string $value, $expire, string $path = null, string $domain = null, bool $secure = null, bool $httpOnly = null, string $sameSite = null);
/**
* Deletes a cookie.
*/
function deleteCookie(string $name, string $path = null, string $domain = null, bool $secure = null);
/**
* @param string|\Closure $body
* @return static
*/
function setBody($body);
/**
* @return string|\Closure
*/
function getBody();
}