# wp-optimize/3.2.7/vendor/rosell-dk/htaccess-capability-tester/src/Testers/RequestHeaderTester.php

WP-Optimize – Cache, Compress images, Minify &amp; Clean database to boost page speed &amp; performance, version 3.2.7. 60 lines.

- Page: https://pluginprobe.com/plugins/wp-optimize/3.2.7/code/vendor/rosell-dk/htaccess-capability-tester/src/Testers/RequestHeaderTester.php
- Raw: https://pluginprobe.com/plugins/wp-optimize/3.2.7/raw/vendor/rosell-dk/htaccess-capability-tester/src/Testers/RequestHeaderTester.php
- Modified: 2021-11-30T14:57:30+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wp-optimize/3.2.7/code/vendor/rosell-dk/htaccess-capability-tester/src/Testers/RequestHeaderTester.php#L10-L20`.

```php
<?php

namespace HtaccessCapabilityTester\Testers;

/**
 * Class for testing if RequestHeader works
 *
 * @package    HtaccessCapabilityTester
 * @author     Bjørn Rosell <it@rosell.dk>
 * @since      Class available since 0.7
 */
class RequestHeaderTester extends CustomTester
{

    /**
     * Constructor.
     *
     * @return void
     */
    public function __construct()
    {
        $htaccessFile = <<<'EOD'
<IfModule mod_headers.c>
  	# Certain hosts seem to strip non-standard request headers,
  	# so we use a standard one to avoid a false negative
    RequestHeader set User-Agent "request-header-test"
</IfModule>
EOD;

        $phpFile = <<<'EOD'
<?php
if (isset($_SERVER['HTTP_USER_AGENT'])) {
    echo (($_SERVER['HTTP_USER_AGENT'] == 'request-header-test') ? "1" : "0");
} else {
    echo "0";
}
EOD;

        // PS:
        // There is a little edge case: When .htaccess is disabled AND phps are either not processed
        // or access is denied. This ought to return *failure*, but it currently returns *inconclusive*.

        $test = [
            'subdir' => 'request-header',
            'files' => [
                ['.htaccess', $htaccessFile],
                ['test.php', $phpFile],
            ],
            'request' => 'test.php',
            'interpretation' => [
                ['success', 'body', 'equals', '1'],
                ['failure', 'body', 'equals', '0'],
                ['inconclusive', 'body', 'begins-with', '<' . '?php'],
            ]
        ];

        parent::__construct($test);
    }
}

```
