• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

codeigniter4 / CodeIgniter4 / 12855700662

19 Jan 2025 05:28PM UTC coverage: 84.546% (+0.08%) from 84.469%
12855700662

push

github

web-flow
Merge pull request #9417 from codeigniter4/4.6

4.6.0 Merge code

720 of 841 new or added lines in 68 files covered. (85.61%)

8 existing lines in 6 files now uncovered.

20811 of 24615 relevant lines covered (84.55%)

191.24 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.89
/system/Filters/ForceHTTPS.php
1
<?php
2

3
declare(strict_types=1);
4

5
/**
6
 * This file is part of CodeIgniter 4 framework.
7
 *
8
 * (c) CodeIgniter Foundation <admin@codeigniter.com>
9
 *
10
 * For the full copyright and license information, please view
11
 * the LICENSE file that was distributed with this source code.
12
 */
13

14
namespace CodeIgniter\Filters;
15

16
use CodeIgniter\HTTP\Exceptions\RedirectException;
17
use CodeIgniter\HTTP\RequestInterface;
18
use CodeIgniter\HTTP\ResponseInterface;
19
use Config\App;
20

21
/**
22
 * Force HTTPS filter
23
 */
24
class ForceHTTPS implements FilterInterface
25
{
26
    /**
27
     * Force Secure Site Access? If the config value 'forceGlobalSecureRequests'
28
     * is true, will enforce that all requests to this site are made through
29
     * HTTPS. Will redirect the user to the current page with HTTPS, as well
30
     * as set the HTTP Strict Transport Security (HSTS) header for those browsers
31
     * that support it.
32
     *
33
     * @param array|null $arguments
34
     *
35
     * @return ResponseInterface|null
36
     */
37
    public function before(RequestInterface $request, $arguments = null)
38
    {
39
        $config = config(App::class);
90✔
40

41
        if ($config->forceGlobalSecureRequests !== true) {
90✔
42
            return null;
88✔
43
        }
44

45
        $response = service('response');
2✔
46

47
        try {
48
            force_https(YEAR, $request, $response);
2✔
49
        } catch (RedirectException $e) {
1✔
50
            return $e->getResponse();
1✔
51
        }
52

53
        return null;
1✔
54
    }
55

56
    /**
57
     * We don't have anything to do here.
58
     *
59
     * @param array|null $arguments
60
     */
61
    public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
62
    {
NEW
63
        return null;
×
64
    }
65
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc