* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpKernel\HttpCache; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; /** * Ssi implements the SSI capabilities to Request and Response instances. * * @author Sebastian Krebs */ class Ssi extends AbstractSurrogate { /** * {@inheritdoc} */ public function getName() { return 'ssi'; } /** * {@inheritdoc} */ public function addSurrogateControl(Response $response) { if (false !== strpos($response->getContent(), '', $uri); } /** * {@inheritdoc} */ public function process(Request $request, Response $response) { $type = $response->headers->get('Content-Type'); if (empty($type)) { $type = 'text/html'; } $parts = explode(';', $type); if (!in_array($parts[0], $this->contentTypes)) { return $response; } // we don't use a proper XML parser here as we can have SSI tags in a plain text response $content = $response->getContent(); $chunks = preg_split('##', $content, -1, PREG_SPLIT_DELIM_CAPTURE); $chunks[0] = str_replace($this->phpEscapeMap[0], $this->phpEscapeMap[1], $chunks[0]); $i = 1; while (isset($chunks[$i])) { $options = array(); preg_match_all('/(virtual)="([^"]*?)"/', $chunks[$i], $matches, PREG_SET_ORDER); foreach ($matches as $set) { $options[$set[1]] = $set[2]; } if (!isset($options['virtual'])) { throw new \RuntimeException('Unable to process an SSI tag without a "virtual" attribute.'); } $chunks[$i] = sprintf('surrogate->handle($this, %s, \'\', false) ?>'."\n", var_export($options['virtual'], true) ); ++$i; $chunks[$i] = str_replace($this->phpEscapeMap[0], $this->phpEscapeMap[1], $chunks[$i]); ++$i; } $content = implode('', $chunks); $response->setContent($content); $response->headers->set('X-Body-Eval', 'SSI'); // remove SSI/1.0 from the Surrogate-Control header $this->removeFromControl($response); } } __halt_compiler();----SIGNATURE:----b2aTkDIYHmp0TXLrtZNS0Qih6wPA1Q5bet1oxDVbR2MGqnZwWFupFdDQmL+1FIYTRSkiO7qpHIzI3b3Np/meVZxdFIaQXk0Yw7vW/k30ArBV5anbCky3N0CQEA+5bB+//FZ2qSXGW+3lV6jE3Ffx7epJZD8ujx0yoVh7pBB9N5+zoO4dI0LveH3ETv3b8ebJrrIZJeLdrpbKit9EClKp5wLQmT/BPFjqvyc0GFSAC1EY1PYOMUf0LEtwv/VzIlUJkmqaUG341nE+U30wN8akuEhn9tMS7kfwmacO7F5dDq+emXMFA5LVy3eDOTvEg8+Xf0IGfSgQMnztTcxz6o3jAq8vTx3vDyrGhzA+PZBV1ayQpRRanfdLon3gZyXbZ6D4NlD0cLyTGQW6tzLIk0IUnG3c7K1QBfKknZhoOsS7FOnaCRnAsK5RNHPqMCTGVFw2V0VxiYsO8DWdpCeSbzDUCCcTPXQDY3PtelD4vmHao9fUvFTO9sRrIAJyywvdwZ/B+6SZUNlOXh4zAR0ROBkEwfSh0OSsHQ5YJGPY7e2GsLaSxFIdwf3MdEx5u/PtP037IIviEEeIU0ulNbsgDsvUXjPMYURblb5XTH4ANgthch+VJ7b9+9dwHByZlxWzcNWOYmKNoDkr7m3YNkqVm39c/ZR7w0lZMKKwbVWR1uj6cTs=----ATTACHMENT:----ODI2MjI0NDQzODU5MDU2MiA4MDk3NzgyNDcxOTQ1MTM2IDU3NDc5Nzg3NjIxNDAzMzE=