@@ -88,34 +88,26 @@ function error_nomirror($mirror) {
88
88
}
89
89
90
90
// Send out a proper status header
91
- function status_header ($ num )
91
+ function status_header (int $ status ): bool
92
92
{
93
- // Set status text
94
- switch ($ num ) {
95
- case 200 : $ status = "OK " ; break ;
96
- case 301 : $ status = "Moved Permanently " ; break ;
97
- case 302 : $ status = "Found " ; break ;
98
- case 404 : $ status = "Not Found " ; break ;
99
- default : return FALSE ;
100
- }
93
+ $ text = [
94
+ 200 => 'OK ' ,
95
+ 301 => 'Moved Permanently ' ,
96
+ 302 => 'Found ' ,
97
+ 404 => 'Not Found ' ,
98
+ ];
99
+ if (!isset ($ text [$ status ])) {
100
+ return false ;
101
+ }
101
102
102
- // Figure out HTTP protocol version - use 1.1 answer for 1.1 request,
103
- // answer with HTTP/1.0 for any other (ancient or futuristic) user
104
- switch (strtoupper ($ _SERVER ['SERVER_PROTOCOL ' ])) {
105
- case 'HTTP/1.0 ' :
106
- @header ("HTTP/1.0 $ num $ status " );
107
- break ;
108
-
109
- case 'HTTP/1.1 ' :
110
- default :
111
- @header ("HTTP/1.1 $ num $ status " );
112
- break ;
113
- }
103
+ // Only respond with HTTP/1.0 for a 1.0 request specifically.
104
+ // Respond with 1.1 for anything else.
105
+ $ proto = strcasecmp ($ _SERVER ['SERVER_PROTOCOL ' ], 'HTTP/1.0 ' ) ? '1.1 ' : '1.0 ' ;
114
106
115
- // BC code for PHP < 4.3.0
116
- @header ("Status: $ num $ status " , TRUE , $ num );
107
+ @ header ( " HTTP/ $ proto $ status { $ text [ $ status ]}" );
108
+ @header ("Status: $ status { $ text [ $ status]} " , true , $ status );
117
109
118
- return TRUE ;
110
+ return true ;
119
111
}
120
112
121
113
/******************************************************************************
0 commit comments