瀏覽代碼

Update Page

Changed the calculation of the version of HTTP
Visman 5 年之前
父節點
當前提交
0aeded510c
共有 1 個文件被更改,包括 7 次插入6 次删除
  1. 7 6
      app/Models/Page.php

+ 7 - 6
app/Models/Page.php

@@ -274,13 +274,14 @@ abstract class Page extends Model
      *
      *
      * @return Page
      * @return Page
      */
      */
-    public function header(string $key, string $value, $replace = true): self
+    public function header(string $key, string $value, bool $replace = true): self
     {
     {
         if ('HTTP/' === \substr($key, 0, 5)) {
         if ('HTTP/' === \substr($key, 0, 5)) {
-            if (\preg_match('%^HTTP/\d\.\d%', $_SERVER['SERVER_PROTOCOL'], $match)) {
-                $key = $match[0];
-            } else {
-                $key = 'HTTP/1.1';
+            if (
+                ! empty($_SERVER['SERVER_PROTOCOL'])
+                && 'HTTP/' === \strtoupper(\substr($_SERVER['SERVER_PROTOCOL'], 0, 5))
+            ) {
+                $key = 'HTTP/' . \substr($_SERVER['SERVER_PROTOCOL'], 5);
             }
             }
         } else {
         } else {
             $key .= ':';
             $key .= ':';
@@ -300,7 +301,7 @@ abstract class Page extends Model
      */
      */
     protected function gethttpHeaders(): array
     protected function gethttpHeaders(): array
     {
     {
-        $now = gmdate('D, d M Y H:i:s') . ' GMT';
+        $now = \gmdate('D, d M Y H:i:s') . ' GMT';
 
 
         $this->httpStatus()
         $this->httpStatus()
             ->header('Cache-Control', 'no-cache, no-store, must-revalidate')
             ->header('Cache-Control', 'no-cache, no-store, must-revalidate')