|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the RHDC Akamai middleware package. |
|
4
|
|
|
* |
|
5
|
|
|
* (c) Shawn Iwinski <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view |
|
8
|
|
|
* the LICENSE file that was distributed with this source code. |
|
9
|
|
|
*/ |
|
10
|
|
|
namespace Rhdc\Akamai\Middleware\Request; |
|
11
|
|
|
|
|
12
|
|
|
use Psr\Http\Message\RequestInterface; |
|
13
|
|
|
|
|
14
|
|
|
class DebugMiddleware implements MiddlewareInterface |
|
15
|
|
|
{ |
|
16
|
|
|
/** |
|
17
|
|
|
* Akamai debug pragma header values |
|
18
|
|
|
* |
|
19
|
|
|
* @var string[] |
|
20
|
|
|
*/ |
|
21
|
|
|
protected static $pragmaHeaders = array( |
|
22
|
|
|
'akamai-x-cache-on', |
|
23
|
|
|
'akamai-x-cache-remote-on', |
|
24
|
|
|
'akamai-x-check-cacheable', |
|
25
|
|
|
'akamai-x-feo-trace', |
|
26
|
|
|
'akamai-x-get-cache-key', |
|
27
|
|
|
'akamai-x-get-client-ip', |
|
28
|
|
|
'akamai-x-get-extracted-values', |
|
29
|
|
|
'akamai-x-get-nonces', |
|
30
|
|
|
'akamai-x-get-request-id', |
|
31
|
|
|
'akamai-x-get-ssl-client-session-id', |
|
32
|
|
|
'akamai-x-get-true-cache-key', |
|
33
|
|
|
'akamai-x-serial-no', |
|
34
|
|
|
); |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Returns array of Akamai debug pragma header values |
|
38
|
|
|
* |
|
39
|
|
|
* @return string[] |
|
40
|
|
|
*/ |
|
41
|
2 |
|
public static function pragmaHeaders() |
|
42
|
|
|
{ |
|
43
|
2 |
|
return static::$pragmaHeaders; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Returns a new modified request instance with Akamai debug pragma headers |
|
48
|
|
|
* |
|
49
|
|
|
* - If the original request does not already have a pragma header, it will |
|
50
|
|
|
* be added with the Akamai debug values |
|
51
|
|
|
* - If the original request already has a pragma header, the Akamai debug |
|
52
|
|
|
* values will be combined with the existing value(s) |
|
53
|
|
|
* |
|
54
|
|
|
* @param RequestInterface $request Original request |
|
55
|
|
|
* |
|
56
|
|
|
* @return RequestInterface New modified request instance with Akamai debug pragma headers |
|
57
|
|
|
*/ |
|
58
|
2 |
|
public function __invoke(RequestInterface $request) |
|
59
|
|
|
{ |
|
60
|
2 |
|
return $request->withAddedHeader('Pragma', static::$pragmaHeaders); |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|