Skip to content

Commit 8b8c5aa

Browse files
authored
Merge pull request #170 from utopia-php/fix-add-missing-status-codes
fix: add missing status codes
2 parents ee4fc6d + 41b74ff commit 8b8c5aa

File tree

3 files changed

+46
-44
lines changed

3 files changed

+46
-44
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ jobs:
1616
php-version: '8.1'
1717

1818
- name: Setup Docker
19-
run: docker-compose up -d --build
19+
run: docker compose up -d --build
2020

2121
- name: Wait for Server to be ready
2222
run: sleep 10
2323

2424
- name: Run FPM Tests
2525
run: docker compose exec fpm vendor/bin/phpunit --configuration phpunit.xml
26-
26+
2727
- name: Run Swoole Tests
28-
run: docker compose exec swoole vendor/bin/phpunit --configuration phpunit.xml
28+
run: docker compose exec swoole vendor/bin/phpunit --configuration phpunit.xml

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ $ git push origin [name_of_your_new_branch]
6666

6767
### Testing
6868

69-
- `docker-compose up -d`
70-
- `docker-compose exec web vendor/bin/phpunit --configuration phpunit.xml`
71-
- `docker-compose exec web vendor/bin/psalm --show-info=true`
69+
- `docker compose up -d`
70+
- `docker compose exec web vendor/bin/phpunit --configuration phpunit.xml`
71+
- `docker compose exec web vendor/bin/psalm --show-info=true`
7272

7373
## Introducing New Features
7474

src/Http/Response.php

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -42,104 +42,91 @@ abstract class Response
4242
* HTTP response status codes
4343
*/
4444
public const STATUS_CODE_CONTINUE = 100;
45-
4645
public const STATUS_CODE_SWITCHING_PROTOCOLS = 101;
46+
public const STATUS_CODE_PROCESSING = 102;
47+
public const STATUS_CODE_EARLY_HINTS = 103;
4748

4849
public const STATUS_CODE_OK = 200;
49-
5050
public const STATUS_CODE_CREATED = 201;
51-
5251
public const STATUS_CODE_ACCEPTED = 202;
53-
5452
public const STATUS_CODE_NON_AUTHORITATIVE_INFORMATION = 203;
55-
5653
public const STATUS_CODE_NOCONTENT = 204;
57-
5854
public const STATUS_CODE_RESETCONTENT = 205;
59-
6055
public const STATUS_CODE_PARTIALCONTENT = 206;
56+
public const STATUS_CODE_MULTI_STATUS = 207;
57+
public const STATUS_CODE_ALREADY_REPORTED = 208;
58+
public const STATUS_CODE_IM_USED = 226;
6159

6260
public const STATUS_CODE_MULTIPLE_CHOICES = 300;
63-
6461
public const STATUS_CODE_MOVED_PERMANENTLY = 301;
65-
6662
public const STATUS_CODE_FOUND = 302;
67-
6863
public const STATUS_CODE_SEE_OTHER = 303;
69-
7064
public const STATUS_CODE_NOT_MODIFIED = 304;
71-
7265
public const STATUS_CODE_USE_PROXY = 305;
73-
7466
public const STATUS_CODE_UNUSED = 306;
75-
7667
public const STATUS_CODE_TEMPORARY_REDIRECT = 307;
68+
public const STATUS_CODE_PERMANENT_REDIRECT = 308;
7769

7870
public const STATUS_CODE_BAD_REQUEST = 400;
79-
8071
public const STATUS_CODE_UNAUTHORIZED = 401;
81-
8272
public const STATUS_CODE_PAYMENT_REQUIRED = 402;
83-
8473
public const STATUS_CODE_FORBIDDEN = 403;
85-
8674
public const STATUS_CODE_NOT_FOUND = 404;
87-
8875
public const STATUS_CODE_METHOD_NOT_ALLOWED = 405;
89-
9076
public const STATUS_CODE_NOT_ACCEPTABLE = 406;
91-
9277
public const STATUS_CODE_PROXY_AUTHENTICATION_REQUIRED = 407;
93-
9478
public const STATUS_CODE_REQUEST_TIMEOUT = 408;
95-
9679
public const STATUS_CODE_CONFLICT = 409;
97-
9880
public const STATUS_CODE_GONE = 410;
99-
10081
public const STATUS_CODE_LENGTH_REQUIRED = 411;
101-
10282
public const STATUS_CODE_PRECONDITION_FAILED = 412;
103-
10483
public const STATUS_CODE_REQUEST_ENTITY_TOO_LARGE = 413;
105-
10684
public const STATUS_CODE_REQUEST_URI_TOO_LONG = 414;
107-
10885
public const STATUS_CODE_UNSUPPORTED_MEDIA_TYPE = 415;
109-
11086
public const STATUS_CODE_REQUESTED_RANGE_NOT_SATISFIABLE = 416;
111-
11287
public const STATUS_CODE_EXPECTATION_FAILED = 417;
113-
88+
public const STATUS_CODE_IM_A_TEAPOT = 418;
89+
public const STATUS_CODE_MISDIRECTED_REQUEST = 421;
90+
public const STATUS_CODE_UNPROCESSABLE_ENTITY = 422;
91+
public const STATUS_CODE_LOCKED = 423;
92+
public const STATUS_CODE_FAILED_DEPENDENCY = 424;
11493
public const STATUS_CODE_TOO_EARLY = 425;
115-
94+
public const STATUS_CODE_UPGRADE_REQUIRED = 426;
95+
public const STATUS_CODE_PRECONDITION_REQUIRED = 428;
11696
public const STATUS_CODE_TOO_MANY_REQUESTS = 429;
97+
public const STATUS_CODE_REQUEST_HEADER_FIELDS_TOO_LARGE = 431;
98+
public const STATUS_CODE_UNAVAILABLE_FOR_LEGAL_REASONS = 451;
11799

118100
public const STATUS_CODE_INTERNAL_SERVER_ERROR = 500;
119-
120101
public const STATUS_CODE_NOT_IMPLEMENTED = 501;
121-
122102
public const STATUS_CODE_BAD_GATEWAY = 502;
123-
124103
public const STATUS_CODE_SERVICE_UNAVAILABLE = 503;
125-
126104
public const STATUS_CODE_GATEWAY_TIMEOUT = 504;
127-
128105
public const STATUS_CODE_HTTP_VERSION_NOT_SUPPORTED = 505;
106+
public const STATUS_CODE_VARIANT_ALSO_NEGOTIATES = 506;
107+
public const STATUS_CODE_INSUFFICIENT_STORAGE = 507;
108+
public const STATUS_CODE_LOOP_DETECTED = 508;
109+
public const STATUS_CODE_NOT_EXTENDED = 510;
110+
public const STATUS_CODE_NETWORK_AUTHENTICATION_REQUIRED = 511;
129111

130112
/**
131113
* @var array
132114
*/
133115
protected $statusCodes = [
134116
self::STATUS_CODE_CONTINUE => 'Continue',
135117
self::STATUS_CODE_SWITCHING_PROTOCOLS => 'Switching Protocols',
118+
self::STATUS_CODE_PROCESSING => 'Processing',
119+
self::STATUS_CODE_EARLY_HINTS => 'Early Hints',
136120
self::STATUS_CODE_OK => 'OK',
137121
self::STATUS_CODE_CREATED => 'Created',
138122
self::STATUS_CODE_ACCEPTED => 'Accepted',
139123
self::STATUS_CODE_NON_AUTHORITATIVE_INFORMATION => 'Non-Authoritative Information',
140124
self::STATUS_CODE_NOCONTENT => 'No Content',
141125
self::STATUS_CODE_RESETCONTENT => 'Reset Content',
142126
self::STATUS_CODE_PARTIALCONTENT => 'Partial Content',
127+
self::STATUS_CODE_MULTI_STATUS => 'Multi-Status',
128+
self::STATUS_CODE_ALREADY_REPORTED => 'Already Reported',
129+
self::STATUS_CODE_IM_USED => 'IM Used',
143130
self::STATUS_CODE_MULTIPLE_CHOICES => 'Multiple Choices',
144131
self::STATUS_CODE_MOVED_PERMANENTLY => 'Moved Permanently',
145132
self::STATUS_CODE_FOUND => 'Found',
@@ -148,6 +135,7 @@ abstract class Response
148135
self::STATUS_CODE_USE_PROXY => 'Use Proxy',
149136
self::STATUS_CODE_UNUSED => '(Unused)',
150137
self::STATUS_CODE_TEMPORARY_REDIRECT => 'Temporary Redirect',
138+
self::STATUS_CODE_PERMANENT_REDIRECT => 'Permanent Redirect',
151139
self::STATUS_CODE_BAD_REQUEST => 'Bad Request',
152140
self::STATUS_CODE_UNAUTHORIZED => 'Unauthorized',
153141
self::STATUS_CODE_PAYMENT_REQUIRED => 'Payment Required',
@@ -166,14 +154,28 @@ abstract class Response
166154
self::STATUS_CODE_UNSUPPORTED_MEDIA_TYPE => 'Unsupported Media Type',
167155
self::STATUS_CODE_REQUESTED_RANGE_NOT_SATISFIABLE => 'Requested Range Not Satisfiable',
168156
self::STATUS_CODE_EXPECTATION_FAILED => 'Expectation Failed',
157+
self::STATUS_CODE_IM_A_TEAPOT => 'I\'m a teapot',
158+
self::STATUS_CODE_MISDIRECTED_REQUEST => 'Misdirected Request',
159+
self::STATUS_CODE_UNPROCESSABLE_ENTITY => 'Unprocessable Entity',
160+
self::STATUS_CODE_LOCKED => 'Locked',
161+
self::STATUS_CODE_FAILED_DEPENDENCY => 'Failed Dependency',
169162
self::STATUS_CODE_TOO_EARLY => 'Too Early',
163+
self::STATUS_CODE_UPGRADE_REQUIRED => 'Upgrade Required',
164+
self::STATUS_CODE_PRECONDITION_REQUIRED => 'Precondition Required',
170165
self::STATUS_CODE_TOO_MANY_REQUESTS => 'Too Many Requests',
166+
self::STATUS_CODE_REQUEST_HEADER_FIELDS_TOO_LARGE => 'Request Header Fields Too Large',
167+
self::STATUS_CODE_UNAVAILABLE_FOR_LEGAL_REASONS => 'Unavailable For Legal Reasons',
171168
self::STATUS_CODE_INTERNAL_SERVER_ERROR => 'Internal Server Error',
172169
self::STATUS_CODE_NOT_IMPLEMENTED => 'Not Implemented',
173170
self::STATUS_CODE_BAD_GATEWAY => 'Bad Gateway',
174171
self::STATUS_CODE_SERVICE_UNAVAILABLE => 'Service Unavailable',
175172
self::STATUS_CODE_GATEWAY_TIMEOUT => 'Gateway Timeout',
176173
self::STATUS_CODE_HTTP_VERSION_NOT_SUPPORTED => 'HTTP Version Not Supported',
174+
self::STATUS_CODE_VARIANT_ALSO_NEGOTIATES => 'Variant Also Negotiates',
175+
self::STATUS_CODE_INSUFFICIENT_STORAGE => 'Insufficient Storage',
176+
self::STATUS_CODE_LOOP_DETECTED => 'Loop Detected',
177+
self::STATUS_CODE_NOT_EXTENDED => 'Not Extended',
178+
self::STATUS_CODE_NETWORK_AUTHENTICATION_REQUIRED => 'Network Authentication Required',
177179
];
178180

179181
/**

0 commit comments

Comments
 (0)