From 617a5dfa44cca82f5e8962a8959580041ae9e3c5 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Mon, 9 Oct 2023 12:33:35 +0200 Subject: [PATCH] Use new HttpStatus utility class in exceptions and TransportMock --- src/Exception/Http/Status304.php | 3 +- src/Exception/Http/Status305.php | 3 +- src/Exception/Http/Status306.php | 3 +- src/Exception/Http/Status400.php | 3 +- src/Exception/Http/Status401.php | 3 +- src/Exception/Http/Status402.php | 3 +- src/Exception/Http/Status403.php | 3 +- src/Exception/Http/Status404.php | 3 +- src/Exception/Http/Status405.php | 3 +- src/Exception/Http/Status406.php | 3 +- src/Exception/Http/Status407.php | 3 +- src/Exception/Http/Status408.php | 3 +- src/Exception/Http/Status409.php | 3 +- src/Exception/Http/Status410.php | 3 +- src/Exception/Http/Status411.php | 3 +- src/Exception/Http/Status412.php | 3 +- src/Exception/Http/Status413.php | 3 +- src/Exception/Http/Status414.php | 3 +- src/Exception/Http/Status415.php | 3 +- src/Exception/Http/Status416.php | 3 +- src/Exception/Http/Status417.php | 3 +- src/Exception/Http/Status418.php | 3 +- src/Exception/Http/Status428.php | 3 +- src/Exception/Http/Status429.php | 3 +- src/Exception/Http/Status431.php | 3 +- src/Exception/Http/Status500.php | 3 +- src/Exception/Http/Status501.php | 3 +- src/Exception/Http/Status502.php | 3 +- src/Exception/Http/Status503.php | 3 +- src/Exception/Http/Status504.php | 3 +- src/Exception/Http/Status505.php | 3 +- src/Exception/Http/Status511.php | 3 +- tests/Fixtures/TransportMock.php | 54 ++------------------------------ 33 files changed, 67 insertions(+), 83 deletions(-) diff --git a/src/Exception/Http/Status304.php b/src/Exception/Http/Status304.php index e14c8ae84..2027a0f49 100644 --- a/src/Exception/Http/Status304.php +++ b/src/Exception/Http/Status304.php @@ -8,6 +8,7 @@ namespace WpOrg\Requests\Exception\Http; use WpOrg\Requests\Exception\Http; +use WpOrg\Requests\Utility\HttpStatus; /** * Exception for 304 Not Modified responses @@ -27,5 +28,5 @@ final class Status304 extends Http { * * @var string */ - protected $reason = 'Not Modified'; + protected $reason = HttpStatus::TEXT_304; } diff --git a/src/Exception/Http/Status305.php b/src/Exception/Http/Status305.php index 6348e6e80..6329d1ba5 100644 --- a/src/Exception/Http/Status305.php +++ b/src/Exception/Http/Status305.php @@ -8,6 +8,7 @@ namespace WpOrg\Requests\Exception\Http; use WpOrg\Requests\Exception\Http; +use WpOrg\Requests\Utility\HttpStatus; /** * Exception for 305 Use Proxy responses @@ -27,5 +28,5 @@ final class Status305 extends Http { * * @var string */ - protected $reason = 'Use Proxy'; + protected $reason = HttpStatus::TEXT_305; } diff --git a/src/Exception/Http/Status306.php b/src/Exception/Http/Status306.php index c6b6f00f1..674f15c8f 100644 --- a/src/Exception/Http/Status306.php +++ b/src/Exception/Http/Status306.php @@ -8,6 +8,7 @@ namespace WpOrg\Requests\Exception\Http; use WpOrg\Requests\Exception\Http; +use WpOrg\Requests\Utility\HttpStatus; /** * Exception for 306 Switch Proxy responses @@ -27,5 +28,5 @@ final class Status306 extends Http { * * @var string */ - protected $reason = 'Switch Proxy'; + protected $reason = HttpStatus::TEXT_306; } diff --git a/src/Exception/Http/Status400.php b/src/Exception/Http/Status400.php index 56d36d3c7..0c8be841b 100644 --- a/src/Exception/Http/Status400.php +++ b/src/Exception/Http/Status400.php @@ -8,6 +8,7 @@ namespace WpOrg\Requests\Exception\Http; use WpOrg\Requests\Exception\Http; +use WpOrg\Requests\Utility\HttpStatus; /** * Exception for 400 Bad Request responses @@ -27,5 +28,5 @@ final class Status400 extends Http { * * @var string */ - protected $reason = 'Bad Request'; + protected $reason = HttpStatus::TEXT_400; } diff --git a/src/Exception/Http/Status401.php b/src/Exception/Http/Status401.php index c7a0b71fd..97e730e5d 100644 --- a/src/Exception/Http/Status401.php +++ b/src/Exception/Http/Status401.php @@ -8,6 +8,7 @@ namespace WpOrg\Requests\Exception\Http; use WpOrg\Requests\Exception\Http; +use WpOrg\Requests\Utility\HttpStatus; /** * Exception for 401 Unauthorized responses @@ -27,5 +28,5 @@ final class Status401 extends Http { * * @var string */ - protected $reason = 'Unauthorized'; + protected $reason = HttpStatus::TEXT_401; } diff --git a/src/Exception/Http/Status402.php b/src/Exception/Http/Status402.php index 722a87c4b..add58cf9c 100644 --- a/src/Exception/Http/Status402.php +++ b/src/Exception/Http/Status402.php @@ -8,6 +8,7 @@ namespace WpOrg\Requests\Exception\Http; use WpOrg\Requests\Exception\Http; +use WpOrg\Requests\Utility\HttpStatus; /** * Exception for 402 Payment Required responses @@ -27,5 +28,5 @@ final class Status402 extends Http { * * @var string */ - protected $reason = 'Payment Required'; + protected $reason = HttpStatus::TEXT_402; } diff --git a/src/Exception/Http/Status403.php b/src/Exception/Http/Status403.php index b6628d642..b92598c63 100644 --- a/src/Exception/Http/Status403.php +++ b/src/Exception/Http/Status403.php @@ -8,6 +8,7 @@ namespace WpOrg\Requests\Exception\Http; use WpOrg\Requests\Exception\Http; +use WpOrg\Requests\Utility\HttpStatus; /** * Exception for 403 Forbidden responses @@ -27,5 +28,5 @@ final class Status403 extends Http { * * @var string */ - protected $reason = 'Forbidden'; + protected $reason = HttpStatus::TEXT_403; } diff --git a/src/Exception/Http/Status404.php b/src/Exception/Http/Status404.php index 37fc6531b..d10d8733c 100644 --- a/src/Exception/Http/Status404.php +++ b/src/Exception/Http/Status404.php @@ -8,6 +8,7 @@ namespace WpOrg\Requests\Exception\Http; use WpOrg\Requests\Exception\Http; +use WpOrg\Requests\Utility\HttpStatus; /** * Exception for 404 Not Found responses @@ -27,5 +28,5 @@ final class Status404 extends Http { * * @var string */ - protected $reason = 'Not Found'; + protected $reason = HttpStatus::TEXT_404; } diff --git a/src/Exception/Http/Status405.php b/src/Exception/Http/Status405.php index f1d1a1ec5..5dd80cccf 100644 --- a/src/Exception/Http/Status405.php +++ b/src/Exception/Http/Status405.php @@ -8,6 +8,7 @@ namespace WpOrg\Requests\Exception\Http; use WpOrg\Requests\Exception\Http; +use WpOrg\Requests\Utility\HttpStatus; /** * Exception for 405 Method Not Allowed responses @@ -27,5 +28,5 @@ final class Status405 extends Http { * * @var string */ - protected $reason = 'Method Not Allowed'; + protected $reason = HttpStatus::TEXT_405; } diff --git a/src/Exception/Http/Status406.php b/src/Exception/Http/Status406.php index 195ce48b5..8c23a0f43 100644 --- a/src/Exception/Http/Status406.php +++ b/src/Exception/Http/Status406.php @@ -8,6 +8,7 @@ namespace WpOrg\Requests\Exception\Http; use WpOrg\Requests\Exception\Http; +use WpOrg\Requests\Utility\HttpStatus; /** * Exception for 406 Not Acceptable responses @@ -27,5 +28,5 @@ final class Status406 extends Http { * * @var string */ - protected $reason = 'Not Acceptable'; + protected $reason = HttpStatus::TEXT_406; } diff --git a/src/Exception/Http/Status407.php b/src/Exception/Http/Status407.php index 20e4b4c6e..c31fb9df0 100644 --- a/src/Exception/Http/Status407.php +++ b/src/Exception/Http/Status407.php @@ -8,6 +8,7 @@ namespace WpOrg\Requests\Exception\Http; use WpOrg\Requests\Exception\Http; +use WpOrg\Requests\Utility\HttpStatus; /** * Exception for 407 Proxy Authentication Required responses @@ -27,5 +28,5 @@ final class Status407 extends Http { * * @var string */ - protected $reason = 'Proxy Authentication Required'; + protected $reason = HttpStatus::TEXT_407; } diff --git a/src/Exception/Http/Status408.php b/src/Exception/Http/Status408.php index 18e8a57f2..ee4514d58 100644 --- a/src/Exception/Http/Status408.php +++ b/src/Exception/Http/Status408.php @@ -8,6 +8,7 @@ namespace WpOrg\Requests\Exception\Http; use WpOrg\Requests\Exception\Http; +use WpOrg\Requests\Utility\HttpStatus; /** * Exception for 408 Request Timeout responses @@ -27,5 +28,5 @@ final class Status408 extends Http { * * @var string */ - protected $reason = 'Request Timeout'; + protected $reason = HttpStatus::TEXT_408; } diff --git a/src/Exception/Http/Status409.php b/src/Exception/Http/Status409.php index df9121fda..7199aff50 100644 --- a/src/Exception/Http/Status409.php +++ b/src/Exception/Http/Status409.php @@ -8,6 +8,7 @@ namespace WpOrg\Requests\Exception\Http; use WpOrg\Requests\Exception\Http; +use WpOrg\Requests\Utility\HttpStatus; /** * Exception for 409 Conflict responses @@ -27,5 +28,5 @@ final class Status409 extends Http { * * @var string */ - protected $reason = 'Conflict'; + protected $reason = HttpStatus::TEXT_409; } diff --git a/src/Exception/Http/Status410.php b/src/Exception/Http/Status410.php index 15d247748..1e730edf3 100644 --- a/src/Exception/Http/Status410.php +++ b/src/Exception/Http/Status410.php @@ -8,6 +8,7 @@ namespace WpOrg\Requests\Exception\Http; use WpOrg\Requests\Exception\Http; +use WpOrg\Requests\Utility\HttpStatus; /** * Exception for 410 Gone responses @@ -27,5 +28,5 @@ final class Status410 extends Http { * * @var string */ - protected $reason = 'Gone'; + protected $reason = HttpStatus::TEXT_410; } diff --git a/src/Exception/Http/Status411.php b/src/Exception/Http/Status411.php index 0bf6156ed..e6a21bb04 100644 --- a/src/Exception/Http/Status411.php +++ b/src/Exception/Http/Status411.php @@ -8,6 +8,7 @@ namespace WpOrg\Requests\Exception\Http; use WpOrg\Requests\Exception\Http; +use WpOrg\Requests\Utility\HttpStatus; /** * Exception for 411 Length Required responses @@ -27,5 +28,5 @@ final class Status411 extends Http { * * @var string */ - protected $reason = 'Length Required'; + protected $reason = HttpStatus::TEXT_411; } diff --git a/src/Exception/Http/Status412.php b/src/Exception/Http/Status412.php index dbc0c2a2e..d9055cb19 100644 --- a/src/Exception/Http/Status412.php +++ b/src/Exception/Http/Status412.php @@ -8,6 +8,7 @@ namespace WpOrg\Requests\Exception\Http; use WpOrg\Requests\Exception\Http; +use WpOrg\Requests\Utility\HttpStatus; /** * Exception for 412 Precondition Failed responses @@ -27,5 +28,5 @@ final class Status412 extends Http { * * @var string */ - protected $reason = 'Precondition Failed'; + protected $reason = HttpStatus::TEXT_412; } diff --git a/src/Exception/Http/Status413.php b/src/Exception/Http/Status413.php index ef10d3e16..19df7c7b6 100644 --- a/src/Exception/Http/Status413.php +++ b/src/Exception/Http/Status413.php @@ -8,6 +8,7 @@ namespace WpOrg\Requests\Exception\Http; use WpOrg\Requests\Exception\Http; +use WpOrg\Requests\Utility\HttpStatus; /** * Exception for 413 Request Entity Too Large responses @@ -27,5 +28,5 @@ final class Status413 extends Http { * * @var string */ - protected $reason = 'Request Entity Too Large'; + protected $reason = HttpStatus::TEXT_413; } diff --git a/src/Exception/Http/Status414.php b/src/Exception/Http/Status414.php index f6baf4146..f2fd122f5 100644 --- a/src/Exception/Http/Status414.php +++ b/src/Exception/Http/Status414.php @@ -8,6 +8,7 @@ namespace WpOrg\Requests\Exception\Http; use WpOrg\Requests\Exception\Http; +use WpOrg\Requests\Utility\HttpStatus; /** * Exception for 414 Request-URI Too Large responses @@ -27,5 +28,5 @@ final class Status414 extends Http { * * @var string */ - protected $reason = 'Request-URI Too Large'; + protected $reason = HttpStatus::TEXT_414; } diff --git a/src/Exception/Http/Status415.php b/src/Exception/Http/Status415.php index 5b5ee417b..ded657d35 100644 --- a/src/Exception/Http/Status415.php +++ b/src/Exception/Http/Status415.php @@ -8,6 +8,7 @@ namespace WpOrg\Requests\Exception\Http; use WpOrg\Requests\Exception\Http; +use WpOrg\Requests\Utility\HttpStatus; /** * Exception for 415 Unsupported Media Type responses @@ -27,5 +28,5 @@ final class Status415 extends Http { * * @var string */ - protected $reason = 'Unsupported Media Type'; + protected $reason = HttpStatus::TEXT_415; } diff --git a/src/Exception/Http/Status416.php b/src/Exception/Http/Status416.php index b7e10b55f..9a3c70761 100644 --- a/src/Exception/Http/Status416.php +++ b/src/Exception/Http/Status416.php @@ -8,6 +8,7 @@ namespace WpOrg\Requests\Exception\Http; use WpOrg\Requests\Exception\Http; +use WpOrg\Requests\Utility\HttpStatus; /** * Exception for 416 Requested Range Not Satisfiable responses @@ -27,5 +28,5 @@ final class Status416 extends Http { * * @var string */ - protected $reason = 'Requested Range Not Satisfiable'; + protected $reason = HttpStatus::TEXT_416; } diff --git a/src/Exception/Http/Status417.php b/src/Exception/Http/Status417.php index 37bdcfffb..6537e9b8d 100644 --- a/src/Exception/Http/Status417.php +++ b/src/Exception/Http/Status417.php @@ -8,6 +8,7 @@ namespace WpOrg\Requests\Exception\Http; use WpOrg\Requests\Exception\Http; +use WpOrg\Requests\Utility\HttpStatus; /** * Exception for 417 Expectation Failed responses @@ -27,5 +28,5 @@ final class Status417 extends Http { * * @var string */ - protected $reason = 'Expectation Failed'; + protected $reason = HttpStatus::TEXT_417; } diff --git a/src/Exception/Http/Status418.php b/src/Exception/Http/Status418.php index 6d2bc787f..973fab86b 100644 --- a/src/Exception/Http/Status418.php +++ b/src/Exception/Http/Status418.php @@ -10,6 +10,7 @@ namespace WpOrg\Requests\Exception\Http; use WpOrg\Requests\Exception\Http; +use WpOrg\Requests\Utility\HttpStatus; /** * Exception for 418 I'm A Teapot responses @@ -31,5 +32,5 @@ final class Status418 extends Http { * * @var string */ - protected $reason = "I'm A Teapot"; + protected $reason = HttpStatus::TEXT_418; } diff --git a/src/Exception/Http/Status428.php b/src/Exception/Http/Status428.php index 62b428f95..cb05f3064 100644 --- a/src/Exception/Http/Status428.php +++ b/src/Exception/Http/Status428.php @@ -10,6 +10,7 @@ namespace WpOrg\Requests\Exception\Http; use WpOrg\Requests\Exception\Http; +use WpOrg\Requests\Utility\HttpStatus; /** * Exception for 428 Precondition Required responses @@ -31,5 +32,5 @@ final class Status428 extends Http { * * @var string */ - protected $reason = 'Precondition Required'; + protected $reason = HttpStatus::TEXT_428; } diff --git a/src/Exception/Http/Status429.php b/src/Exception/Http/Status429.php index dbefd7e7d..9f70ed902 100644 --- a/src/Exception/Http/Status429.php +++ b/src/Exception/Http/Status429.php @@ -10,6 +10,7 @@ namespace WpOrg\Requests\Exception\Http; use WpOrg\Requests\Exception\Http; +use WpOrg\Requests\Utility\HttpStatus; /** * Exception for 429 Too Many Requests responses @@ -31,5 +32,5 @@ final class Status429 extends Http { * * @var string */ - protected $reason = 'Too Many Requests'; + protected $reason = HttpStatus::TEXT_429; } diff --git a/src/Exception/Http/Status431.php b/src/Exception/Http/Status431.php index 6a9377e88..ee89395bc 100644 --- a/src/Exception/Http/Status431.php +++ b/src/Exception/Http/Status431.php @@ -10,6 +10,7 @@ namespace WpOrg\Requests\Exception\Http; use WpOrg\Requests\Exception\Http; +use WpOrg\Requests\Utility\HttpStatus; /** * Exception for 431 Request Header Fields Too Large responses @@ -31,5 +32,5 @@ final class Status431 extends Http { * * @var string */ - protected $reason = 'Request Header Fields Too Large'; + protected $reason = HttpStatus::TEXT_431; } diff --git a/src/Exception/Http/Status500.php b/src/Exception/Http/Status500.php index 1c8bc052f..8dacd2a8b 100644 --- a/src/Exception/Http/Status500.php +++ b/src/Exception/Http/Status500.php @@ -8,6 +8,7 @@ namespace WpOrg\Requests\Exception\Http; use WpOrg\Requests\Exception\Http; +use WpOrg\Requests\Utility\HttpStatus; /** * Exception for 500 Internal Server Error responses @@ -27,5 +28,5 @@ final class Status500 extends Http { * * @var string */ - protected $reason = 'Internal Server Error'; + protected $reason = HttpStatus::TEXT_500; } diff --git a/src/Exception/Http/Status501.php b/src/Exception/Http/Status501.php index 297c3bbde..5308da132 100644 --- a/src/Exception/Http/Status501.php +++ b/src/Exception/Http/Status501.php @@ -8,6 +8,7 @@ namespace WpOrg\Requests\Exception\Http; use WpOrg\Requests\Exception\Http; +use WpOrg\Requests\Utility\HttpStatus; /** * Exception for 501 Not Implemented responses @@ -27,5 +28,5 @@ final class Status501 extends Http { * * @var string */ - protected $reason = 'Not Implemented'; + protected $reason = HttpStatus::TEXT_501; } diff --git a/src/Exception/Http/Status502.php b/src/Exception/Http/Status502.php index cdceef2a6..a00717b83 100644 --- a/src/Exception/Http/Status502.php +++ b/src/Exception/Http/Status502.php @@ -8,6 +8,7 @@ namespace WpOrg\Requests\Exception\Http; use WpOrg\Requests\Exception\Http; +use WpOrg\Requests\Utility\HttpStatus; /** * Exception for 502 Bad Gateway responses @@ -27,5 +28,5 @@ final class Status502 extends Http { * * @var string */ - protected $reason = 'Bad Gateway'; + protected $reason = HttpStatus::TEXT_502; } diff --git a/src/Exception/Http/Status503.php b/src/Exception/Http/Status503.php index 7c449c748..b1a79a9e8 100644 --- a/src/Exception/Http/Status503.php +++ b/src/Exception/Http/Status503.php @@ -8,6 +8,7 @@ namespace WpOrg\Requests\Exception\Http; use WpOrg\Requests\Exception\Http; +use WpOrg\Requests\Utility\HttpStatus; /** * Exception for 503 Service Unavailable responses @@ -27,5 +28,5 @@ final class Status503 extends Http { * * @var string */ - protected $reason = 'Service Unavailable'; + protected $reason = HttpStatus::TEXT_503; } diff --git a/src/Exception/Http/Status504.php b/src/Exception/Http/Status504.php index 19a06c756..0c997ce68 100644 --- a/src/Exception/Http/Status504.php +++ b/src/Exception/Http/Status504.php @@ -8,6 +8,7 @@ namespace WpOrg\Requests\Exception\Http; use WpOrg\Requests\Exception\Http; +use WpOrg\Requests\Utility\HttpStatus; /** * Exception for 504 Gateway Timeout responses @@ -27,5 +28,5 @@ final class Status504 extends Http { * * @var string */ - protected $reason = 'Gateway Timeout'; + protected $reason = HttpStatus::TEXT_504; } diff --git a/src/Exception/Http/Status505.php b/src/Exception/Http/Status505.php index 50bd905a4..5e377a27a 100644 --- a/src/Exception/Http/Status505.php +++ b/src/Exception/Http/Status505.php @@ -8,6 +8,7 @@ namespace WpOrg\Requests\Exception\Http; use WpOrg\Requests\Exception\Http; +use WpOrg\Requests\Utility\HttpStatus; /** * Exception for 505 HTTP Version Not Supported responses @@ -27,5 +28,5 @@ final class Status505 extends Http { * * @var string */ - protected $reason = 'HTTP Version Not Supported'; + protected $reason = HttpStatus::TEXT_505; } diff --git a/src/Exception/Http/Status511.php b/src/Exception/Http/Status511.php index 3b3050665..0a99e6fa8 100644 --- a/src/Exception/Http/Status511.php +++ b/src/Exception/Http/Status511.php @@ -10,6 +10,7 @@ namespace WpOrg\Requests\Exception\Http; use WpOrg\Requests\Exception\Http; +use WpOrg\Requests\Utility\HttpStatus; /** * Exception for 511 Network Authentication Required responses @@ -31,5 +32,5 @@ final class Status511 extends Http { * * @var string */ - protected $reason = 'Network Authentication Required'; + protected $reason = HttpStatus::TEXT_511; } diff --git a/tests/Fixtures/TransportMock.php b/tests/Fixtures/TransportMock.php index 8bcd38fbb..dfea35025 100644 --- a/tests/Fixtures/TransportMock.php +++ b/tests/Fixtures/TransportMock.php @@ -3,6 +3,7 @@ namespace WpOrg\Requests\Tests\Fixtures; use WpOrg\Requests\Transport; +use WpOrg\Requests\Utility\HttpStatus; final class TransportMock implements Transport { public $code = 200; @@ -10,58 +11,9 @@ final class TransportMock implements Transport { public $body = 'Test Body'; public $raw_headers = ''; - private static $messages = [ - 100 => '100 Continue', - 101 => '101 Switching Protocols', - 200 => '200 OK', - 201 => '201 Created', - 202 => '202 Accepted', - 203 => '203 Non-Authoritative Information', - 204 => '204 No Content', - 205 => '205 Reset Content', - 206 => '206 Partial Content', - 300 => '300 Multiple Choices', - 301 => '301 Moved Permanently', - 302 => '302 Found', - 303 => '303 See Other', - 304 => '304 Not Modified', - 305 => '305 Use Proxy', - 306 => '306 (Unused)', - 307 => '307 Temporary Redirect', - 400 => '400 Bad Request', - 401 => '401 Unauthorized', - 402 => '402 Payment Required', - 403 => '403 Forbidden', - 404 => '404 Not Found', - 405 => '405 Method Not Allowed', - 406 => '406 Not Acceptable', - 407 => '407 Proxy Authentication Required', - 408 => '408 Request Timeout', - 409 => '409 Conflict', - 410 => '410 Gone', - 411 => '411 Length Required', - 412 => '412 Precondition Failed', - 413 => '413 Request Entity Too Large', - 414 => '414 Request-URI Too Long', - 415 => '415 Unsupported Media Type', - 416 => '416 Requested Range Not Satisfiable', - 417 => '417 Expectation Failed', - 418 => '418 I\'m a teapot', - 428 => '428 Precondition Required', - 429 => '429 Too Many Requests', - 431 => '431 Request Header Fields Too Large', - 500 => '500 Internal Server Error', - 501 => '501 Not Implemented', - 502 => '502 Bad Gateway', - 503 => '503 Service Unavailable', - 504 => '504 Gateway Timeout', - 505 => '505 HTTP Version Not Supported', - 511 => '511 Network Authentication Required', - ]; - public function request($url, $headers = [], $data = [], $options = []) { - $status = isset(self::$messages[$this->code]) ? self::$messages[$this->code] : $this->code . ' unknown'; - $response = "HTTP/1.0 $status\r\n"; + $text = HttpStatus::is_valid_code($this->code) ? HttpStatus::get_text($this->code) : 'unknown'; + $response = "HTTP/1.0 {$this->code} {$text}\r\n"; $response .= "Content-Type: text/plain\r\n"; if ($this->chunked) { $response .= "Transfer-Encoding: chunked\r\n";