Browse Source

backport https detector from 5.x

Kevin Pfeifer 3 years ago
parent
commit
eacf7661fe
2 changed files with 6 additions and 0 deletions
  1. 1 0
      src/Http/ServerRequest.php
  2. 5 0
      tests/TestCase/Http/ServerRequestTest.php

+ 1 - 0
src/Http/ServerRequest.php

@@ -127,6 +127,7 @@ class ServerRequest implements ServerRequestInterface
         'head' => ['env' => 'REQUEST_METHOD', 'value' => 'HEAD'],
         'options' => ['env' => 'REQUEST_METHOD', 'value' => 'OPTIONS'],
         'ssl' => ['env' => 'HTTPS', 'options' => [1, 'on']],
+        'https' => ['env' => 'HTTPS', 'options' => [1, 'on']],
         'ajax' => ['env' => 'HTTP_X_REQUESTED_WITH', 'value' => 'XMLHttpRequest'],
         'json' => ['accept' => ['application/json'], 'param' => '_ext', 'value' => 'json'],
         'xml' => [

+ 5 - 0
tests/TestCase/Http/ServerRequestTest.php

@@ -747,18 +747,23 @@ class ServerRequestTest extends TestCase
 
         $request = $request->withEnv('HTTPS', 'on');
         $this->assertTrue($request->is('ssl'));
+        $this->assertTrue($request->is('https'));
 
         $request = $request->withEnv('HTTPS', '1');
         $this->assertTrue($request->is('ssl'));
+        $this->assertTrue($request->is('https'));
 
         $request = $request->withEnv('HTTPS', 'I am not empty');
         $this->assertFalse($request->is('ssl'));
+        $this->assertFalse($request->is('https'));
 
         $request = $request->withEnv('HTTPS', 'off');
         $this->assertFalse($request->is('ssl'));
+        $this->assertFalse($request->is('https'));
 
         $request = $request->withEnv('HTTPS', '');
         $this->assertFalse($request->is('ssl'));
+        $this->assertFalse($request->is('https'));
     }
 
     /**