Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
Response.php
001 <?php
002
003 namespace GuzzleHttp\Psr7;
004
005 use Psr\Http\Message\ResponseInterface;
006 use Psr\Http\Message\StreamInterface;
007
008 /**
009 * PSR-7 response implementation.
010 */
011 class Response implements ResponseInterface
012 {
013 use MessageTrait;
014
015 /** @var array Map of standard HTTP status code/reason phrases */
016 private static $phrases = [
017 100 => 'Continue',
018 101 => 'Switching Protocols',
019 102 => 'Processing',
020 200 => 'OK',
021 201 => 'Created',
022 202 => 'Accepted',
023 203 => 'Non-Authoritative Information',
024 204 => 'No Content',
025 205 => 'Reset Content',
026 206 => 'Partial Content',
027 207 => 'Multi-status',
028 208 => 'Already Reported',
029 300 => 'Multiple Choices',
030 301 => 'Moved Permanently',
031 302 => 'Found',
032 303 => 'See Other',
033 304 => 'Not Modified',
034 305 => 'Use Proxy',
035 306 => 'Switch Proxy',
036 307 => 'Temporary Redirect',
037 400 => 'Bad Request',
038 401 => 'Unauthorized',
039 402 => 'Payment Required',
040 403 => 'Forbidden',
041 404 => 'Not Found',
042 405 => 'Method Not Allowed',
043 406 => 'Not Acceptable',
044 407 => 'Proxy Authentication Required',
045 408 => 'Request Time-out',
046 409 => 'Conflict',
047 410 => 'Gone',
048 411 => 'Length Required',
049 412 => 'Precondition Failed',
050 413 => 'Request Entity Too Large',
051 414 => 'Request-URI Too Large',
052 415 => 'Unsupported Media Type',
053 416 => 'Requested range not satisfiable',
054 417 => 'Expectation Failed',
055 418 => 'I\'m a teapot',
056 422 => 'Unprocessable Entity',
057 423 => 'Locked',
058 424 => 'Failed Dependency',
059 425 => 'Unordered Collection',
060 426 => 'Upgrade Required',
061 428 => 'Precondition Required',
062 429 => 'Too Many Requests',
063 431 => 'Request Header Fields Too Large',
064 451 => 'Unavailable For Legal Reasons',
065 500 => 'Internal Server Error',
066 501 => 'Not Implemented',
067 502 => 'Bad Gateway',
068 503 => 'Service Unavailable',
069 504 => 'Gateway Time-out',
070 505 => 'HTTP Version not supported',
071 506 => 'Variant Also Negotiates',
072 507 => 'Insufficient Storage',
073 508 => 'Loop Detected',
074 511 => 'Network Authentication Required',
075 ];
076
077 /** @var string */
078 private $reasonPhrase = '';
079
080 /** @var int */
081 private $statusCode = 200;
082
083 /**
084 * @param int $status Status code
085 * @param array $headers Response headers
086 * @param string|resource|StreamInterface|null $body Response body
087 * @param string $version Protocol version
088 * @param string|null $reason Reason phrase (when empty a default will be used based on the status code)
089 */
090 public function __construct(
091 $status = 200,
092 array $headers = [],
093 $body = null,
094 $version = '1.1',
095 $reason = null
096 ) {
097 $this->assertStatusCodeIsInteger($status);
098 $status = (int) $status;
099 $this->assertStatusCodeRange($status);
100
101 $this->statusCode = $status;
102
103 if ($body !== '' && $body !== null) {
104 $this->stream = Utils::streamFor($body);
105 }
106
107 $this->setHeaders($headers);
108 if ($reason == '' && isset(self::$phrases[$this->statusCode])) {
109 $this->reasonPhrase = self::$phrases[$this->statusCode];
110 } else {
111 $this->reasonPhrase = (string) $reason;
112 }
113
114 $this->protocol = $version;
115 }
116
117 public function getStatusCode()
118 {
119 return $this->statusCode;
120 }
121
122 public function getReasonPhrase()
123 {
124 return $this->reasonPhrase;
125 }
126
127 public function withStatus($code, $reasonPhrase = '')
128 {
129 $this->assertStatusCodeIsInteger($code);
130 $code = (int) $code;
131 $this->assertStatusCodeRange($code);
132
133 $new = clone $this;
134 $new->statusCode = $code;
135 if ($reasonPhrase == '' && isset(self::$phrases[$new->statusCode])) {
136 $reasonPhrase = self::$phrases[$new->statusCode];
137 }
138 $new->reasonPhrase = (string) $reasonPhrase;
139 return $new;
140 }
141
142 private function assertStatusCodeIsInteger($statusCode)
143 {
144 if (filter_var($statusCode, FILTER_VALIDATE_INT) === false) {
145 throw new \InvalidArgumentException('Status code must be an integer value.');
146 }
147 }
148
149 private function assertStatusCodeRange($statusCode)
150 {
151 if ($statusCode < 100 || $statusCode >= 600) {
152 throw new \InvalidArgumentException('Status code must be an integer value between 1xx and 5xx.');
153 }
154 }
155 }
156