6868#include "zend_hash.h"
6969#include "zend_modules.h"
7070#include "fopen_wrappers.h"
71+ #include "http_status_codes.h"
7172
7273#include "zend_compile.h"
7374#include "zend_execute.h"
@@ -203,55 +204,6 @@ typedef struct php_cli_server_http_response_status_code_pair {
203204 const char * str ;
204205} php_cli_server_http_response_status_code_pair ;
205206
206- static php_cli_server_http_response_status_code_pair status_map [] = {
207- { 100 , "Continue" },
208- { 101 , "Switching Protocols" },
209- { 200 , "OK" },
210- { 201 , "Created" },
211- { 202 , "Accepted" },
212- { 203 , "Non-Authoritative Information" },
213- { 204 , "No Content" },
214- { 205 , "Reset Content" },
215- { 206 , "Partial Content" },
216- { 300 , "Multiple Choices" },
217- { 301 , "Moved Permanently" },
218- { 302 , "Found" },
219- { 303 , "See Other" },
220- { 304 , "Not Modified" },
221- { 305 , "Use Proxy" },
222- { 307 , "Temporary Redirect" },
223- { 308 , "Permanent Redirect" },
224- { 400 , "Bad Request" },
225- { 401 , "Unauthorized" },
226- { 402 , "Payment Required" },
227- { 403 , "Forbidden" },
228- { 404 , "Not Found" },
229- { 405 , "Method Not Allowed" },
230- { 406 , "Not Acceptable" },
231- { 407 , "Proxy Authentication Required" },
232- { 408 , "Request Timeout" },
233- { 409 , "Conflict" },
234- { 410 , "Gone" },
235- { 411 , "Length Required" },
236- { 412 , "Precondition Failed" },
237- { 413 , "Request Entity Too Large" },
238- { 414 , "Request-URI Too Long" },
239- { 415 , "Unsupported Media Type" },
240- { 416 , "Requested Range Not Satisfiable" },
241- { 417 , "Expectation Failed" },
242- { 426 , "Upgrade Required" },
243- { 428 , "Precondition Required" },
244- { 429 , "Too Many Requests" },
245- { 431 , "Request Header Fields Too Large" },
246- { 500 , "Internal Server Error" },
247- { 501 , "Not Implemented" },
248- { 502 , "Bad Gateway" },
249- { 503 , "Service Unavailable" },
250- { 504 , "Gateway Timeout" },
251- { 505 , "HTTP Version Not Supported" },
252- { 511 , "Network Authentication Required" },
253- };
254-
255207static php_cli_server_http_response_status_code_pair template_map [] = {
256208 { 400 , "<h1>%s</h1><p>Your browser sent a request that this server could not understand.</p>" },
257209 { 404 , "<h1>%s</h1><p>The requested resource <code class=\"url\">%s</code> was not found on this server.</p>" },
@@ -324,8 +276,8 @@ static char *get_last_error() /* {{{ */
324276
325277static int status_comp (const void * a , const void * b ) /* {{{ */
326278{
327- const php_cli_server_http_response_status_code_pair * pa = (const php_cli_server_http_response_status_code_pair * ) a ;
328- const php_cli_server_http_response_status_code_pair * pb = (const php_cli_server_http_response_status_code_pair * ) b ;
279+ const http_response_status_code_pair * pa = (const http_response_status_code_pair * ) a ;
280+ const http_response_status_code_pair * pb = (const http_response_status_code_pair * ) b ;
329281
330282 if (pa -> code < pb -> code ) {
331283 return -1 ;
@@ -338,12 +290,10 @@ static int status_comp(const void *a, const void *b) /* {{{ */
338290
339291static const char * get_status_string (int code ) /* {{{ */
340292{
341- php_cli_server_http_response_status_code_pair needle , * result = NULL ;
342-
343- needle .code = code ;
344- needle .str = NULL ;
293+ http_response_status_code_pair needle = {code , NULL },
294+ * result = NULL ;
345295
346- result = bsearch (& needle , status_map , sizeof ( status_map ) / sizeof ( needle ) , sizeof (needle ), status_comp );
296+ result = bsearch (& needle , http_status_map , http_status_map_len , sizeof (needle ), status_comp );
347297
348298 if (result ) {
349299 return result -> str ;
0 commit comments