Преглед изворни кода

Fix set http headers in Message page

Visman пре 4 година
родитељ
комит
630aff0484
2 измењених фајлова са 17 додато и 6 уклоњено
  1. 8 1
      app/Controllers/Routing.php
  2. 9 5
      app/Models/Pages/Message.php

+ 8 - 1
app/Controllers/Routing.php

@@ -643,7 +643,14 @@ class Routing
                 break;
                 break;
             case $r::METHOD_NOT_ALLOWED:
             case $r::METHOD_NOT_ALLOWED:
                 // ... 405 Method Not Allowed
                 // ... 405 Method Not Allowed
-                $page = $this->c->Message->message('Bad request', true, 405, ['Allow: ' . \implode(',', $route[1])]);
+                $page = $this->c->Message->message(
+                    'Bad request',
+                    true,
+                    405,
+                    [
+                        ['Allow', \implode(',', $route[1])],
+                    ]
+                );
                 break;
                 break;
             case $r::NOT_IMPLEMENTED:
             case $r::NOT_IMPLEMENTED:
                 // ... 501 Not implemented
                 // ... 501 Not implemented

+ 9 - 5
app/Models/Pages/Message.php

@@ -19,12 +19,16 @@ class Message extends Page
      */
      */
     public function message(string $message, bool $back = true, int $status = 404, array $headers = []): Page
     public function message(string $message, bool $back = true, int $status = 404, array $headers = []): Page
     {
     {
-        $this->nameTpl     = 'message';
-        $this->httpStatus  = \max(200, $status);
-        $this->httpHeaders = $headers;
-        $this->titles      = __('Info');
-        $this->back        = $back;
+        $this->nameTpl    = 'message';
+        $this->httpStatus = \max(200, $status);
+        $this->titles     = __('Info');
+        $this->back       = $back;
 
 
+        if (! empty($headers)) {
+            foreach ($headers as $header) {
+                $this->header($header[0], $header[1], $header[2] ?? true);
+            }
+        }
 
 
         if ($status < 200) {
         if ($status < 200) {
             $type = 'i';
             $type = 'i';