| 148 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/*
|
|
|
4 |
* This file is part of the Symfony package.
|
|
|
5 |
*
|
|
|
6 |
* (c) Fabien Potencier <fabien@symfony.com>
|
|
|
7 |
*
|
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
|
|
9 |
* file that was distributed with this source code.
|
|
|
10 |
*/
|
|
|
11 |
|
|
|
12 |
namespace Symfony\Component\HttpKernel\HttpCache;
|
|
|
13 |
|
|
|
14 |
use Symfony\Component\HttpFoundation\Request;
|
|
|
15 |
use Symfony\Component\HttpFoundation\Response;
|
|
|
16 |
|
|
|
17 |
interface SurrogateInterface
|
|
|
18 |
{
|
|
|
19 |
/**
|
|
|
20 |
* Returns surrogate name.
|
|
|
21 |
*/
|
|
|
22 |
public function getName(): string;
|
|
|
23 |
|
|
|
24 |
/**
|
|
|
25 |
* Returns a new cache strategy instance.
|
|
|
26 |
*/
|
|
|
27 |
public function createCacheStrategy(): ResponseCacheStrategyInterface;
|
|
|
28 |
|
|
|
29 |
/**
|
|
|
30 |
* Checks that at least one surrogate has Surrogate capability.
|
|
|
31 |
*/
|
|
|
32 |
public function hasSurrogateCapability(Request $request): bool;
|
|
|
33 |
|
|
|
34 |
/**
|
|
|
35 |
* Adds Surrogate-capability to the given Request.
|
|
|
36 |
*/
|
|
|
37 |
public function addSurrogateCapability(Request $request);
|
|
|
38 |
|
|
|
39 |
/**
|
|
|
40 |
* Adds HTTP headers to specify that the Response needs to be parsed for Surrogate.
|
|
|
41 |
*
|
|
|
42 |
* This method only adds an Surrogate HTTP header if the Response has some Surrogate tags.
|
|
|
43 |
*/
|
|
|
44 |
public function addSurrogateControl(Response $response);
|
|
|
45 |
|
|
|
46 |
/**
|
|
|
47 |
* Checks that the Response needs to be parsed for Surrogate tags.
|
|
|
48 |
*/
|
|
|
49 |
public function needsParsing(Response $response): bool;
|
|
|
50 |
|
|
|
51 |
/**
|
|
|
52 |
* Renders a Surrogate tag.
|
|
|
53 |
*
|
| 688 |
lars |
54 |
* @param string|null $alt An alternate URI
|
|
|
55 |
* @param string $comment A comment to add as an esi:include tag
|
| 148 |
lars |
56 |
*/
|
|
|
57 |
public function renderIncludeTag(string $uri, string $alt = null, bool $ignoreErrors = true, string $comment = ''): string;
|
|
|
58 |
|
|
|
59 |
/**
|
|
|
60 |
* Replaces a Response Surrogate tags with the included resource content.
|
|
|
61 |
*/
|
|
|
62 |
public function process(Request $request, Response $response): Response;
|
|
|
63 |
|
|
|
64 |
/**
|
|
|
65 |
* Handles a Surrogate from the cache.
|
|
|
66 |
*
|
|
|
67 |
* @param string $alt An alternative URI
|
|
|
68 |
*
|
|
|
69 |
* @throws \RuntimeException
|
|
|
70 |
* @throws \Exception
|
|
|
71 |
*/
|
|
|
72 |
public function handle(HttpCache $cache, string $uri, string $alt, bool $ignoreErrors): string;
|
|
|
73 |
}
|