@@ -287,8 +287,7 @@ public static function checkMaintenanceMode() {
287287 // Allow ajax update script to execute without being stopped
288288 if (\OC ::$ server ->getSystemConfig ()->getValue ('maintenance ' , false ) && OC ::$ SUBURI != '/core/ajax/update.php ' ) {
289289 // send http status 503
290- header ('HTTP/1.1 503 Service Temporarily Unavailable ' );
291- header ('Status: 503 Service Temporarily Unavailable ' );
290+ http_response_code (503 );
292291 header ('Retry-After: 120 ' );
293292
294293 // render error page
@@ -344,8 +343,7 @@ private static function printUpgradePage(\OC\SystemConfig $systemConfig) {
344343
345344 if ($ disableWebUpdater || ($ tooBig && !$ ignoreTooBigWarning )) {
346345 // send http status 503
347- header ('HTTP/1.1 503 Service Temporarily Unavailable ' );
348- header ('Status: 503 Service Temporarily Unavailable ' );
346+ http_response_code (503 );
349347 header ('Retry-After: 120 ' );
350348
351349 // render error page
@@ -600,9 +598,7 @@ public static function init() {
600598
601599 } catch (\RuntimeException $ e ) {
602600 if (!self ::$ CLI ) {
603- $ claimedProtocol = strtoupper ($ _SERVER ['SERVER_PROTOCOL ' ]);
604- $ protocol = in_array ($ claimedProtocol , ['HTTP/1.0 ' , 'HTTP/1.1 ' , 'HTTP/2 ' ]) ? $ claimedProtocol : 'HTTP/1.1 ' ;
605- header ($ protocol . ' ' . OC_Response::STATUS_SERVICE_UNAVAILABLE );
601+ http_response_code (503 );
606602 }
607603 // we can't use the template error page here, because this needs the
608604 // DI container which isn't available yet
@@ -689,7 +685,7 @@ public static function init() {
689685 }
690686 exit (1 );
691687 } else {
692- OC_Response:: setStatus (OC_Response:: STATUS_SERVICE_UNAVAILABLE );
688+ http_response_code ( 503 );
693689 OC_Util::addStyle ('guest ' );
694690 OC_Template::printGuestPage ('' , 'error ' , array ('errors ' => $ errors ));
695691 exit ;
@@ -778,16 +774,14 @@ public static function init() {
778774 }
779775
780776 if (substr ($ request ->getRequestUri (), -11 ) === '/status.php ' ) {
781- OC_Response::setStatus (\OC_Response::STATUS_BAD_REQUEST );
782- header ('Status: 400 Bad Request ' );
777+ http_response_code (400 );
783778 header ('Content-Type: application/json ' );
784779 echo '{"error": "Trusted domain error.", "code": 15} ' ;
785780 exit ();
786781 }
787782
788783 if (!$ isScssRequest ) {
789- OC_Response::setStatus (\OC_Response::STATUS_BAD_REQUEST );
790- header ('Status: 400 Bad Request ' );
784+ http_response_code (400 );
791785
792786 \OC ::$ server ->getLogger ()->info (
793787 'Trusted domain error. "{remoteAddress}" tried to access using "{host}" as host. ' ,
@@ -997,7 +991,7 @@ public static function handleRequest() {
997991 } catch (Symfony \Component \Routing \Exception \ResourceNotFoundException $ e ) {
998992 //header('HTTP/1.0 404 Not Found');
999993 } catch (Symfony \Component \Routing \Exception \MethodNotAllowedException $ e ) {
1000- OC_Response:: setStatus (405 );
994+ http_response_code (405 );
1001995 return ;
1002996 }
1003997 }
@@ -1007,8 +1001,7 @@ public static function handleRequest() {
10071001 // not allowed any more to prevent people
10081002 // mounting this root directly.
10091003 // Users need to mount remote.php/webdav instead.
1010- header ('HTTP/1.1 405 Method Not Allowed ' );
1011- header ('Status: 405 Method Not Allowed ' );
1004+ http_response_code (405 );
10121005 return ;
10131006 }
10141007
0 commit comments