* * 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:----DbZMn1UjhVvC1b+88p1N6GCdxnZBqX/nU3nl7Db2TvWwfRgI/f+QJOL1aloutJ6yh9RW7bO4EsJDCoK/VUh+aa81QJtYiKrKyYQSSHw8nBUxpD/do4He/+JvewDJhc7znshlWuiYTKQfgJOGj/2h8SaVUwquW1yAf79nUkpMIk79ZK9l1PnTkaJL9KVHexiaVsvlYCuhnHtlLdss7pikdAiHkjAQB+Jp87iIv9KvuXT4iV5ufCcmEItT2JR5KInbBarUQg+9gEp9ZkYibQqhzYH1/MGjt2XHFPGDWWgn7Sb+BxHVrjED7Donvf72OE7O/PRuAyomyfRN9yMzl+tcxklxvhJzJHfhPILwwd1W4C48ln1LXJTue1p+QSXmmcbGCAbMMrpxkwKRTTiY7jvC2lRUW9idg6dbEwN8tyPPJTA60eeiWH2cvq2eS7xML2SBi9XXhDBtgNIN21mM2XLEn7Twzq05dGLgHVwmgP3tzu+gUyNmb2VhosgyNZHWpBEyjtJT+U9hgPniDv+5PdzOEqW6RXdmccmih8sCKxLAHeqqFR479Eg3rkC+57cDiz76cp+sGEWSTjvY84261EB+w7axkyGvuVPccJcKEsvsKAAB5NN8Pt7iw3Fk4gCttMBw9GP0ByIT2S4r/uSY631OlsRJrXTXjRg2Rz/Omnris5Y=----ATTACHMENT:----MjQzNjkxNzI2NDI3OTEyMiAxNzE1NjcwOTcxNzI3OTMzIDcxNTIzMDcwMzQ2NzI2MzA=