Пример #1
0
 public function afterExecution()
 {
     //report execution time in header (not in response body, that will ruin the etag)
     $this->response->setHttpHeader('Ls-Execution-Time', LsApi::getResponseTime());
     // Etag support
     if (sfConfig::get('sf_etag')) {
         $etag = '"' . md5($this->response->getContent()) . '"';
         $this->response->setHttpHeader('ETag', $etag);
         if ($this->request->getHttpHeader('IF_NONE_MATCH') == $etag) {
             $this->response->setStatusCode(304);
             $this->response->setHeaderOnly(true);
             if (sfConfig::get('sf_logging_enabled')) {
                 $this->context->getEventDispatcher()->notify(new sfEvent($this, 'application.log', array('ETag matches If-None-Match (send 304)')));
             }
         }
     }
     // conditional GET support
     // never in debug mode
     if ($this->response->hasHttpHeader('Last-Modified') && !sfConfig::get('sf_debug')) {
         $last_modified = $this->response->getHttpHeader('Last-Modified');
         if ($this->request->getHttpHeader('IF_MODIFIED_SINCE') == $last_modified) {
             $this->response->setStatusCode(304);
             $this->response->setHeaderOnly(true);
             if (sfConfig::get('sf_logging_enabled')) {
                 $this->context->getEventDispatcher()->notify(new sfEvent($this, 'application.log', array('Last-Modified matches If-Modified-Since (send 304)')));
             }
         }
     }
 }
Пример #2
0
<?php

ob_start();
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
?>
<Response>
  <Meta>
    <ExecutionTime><?php 
echo LsApi::getResponseTime();
?>
</ExecutionTime>
  </Meta>
  <Data>
    <?php 
echo $sf_content;
?>
  </Data>
</Response>
<?php 
$xml = ob_get_contents();
ob_end_clean();
echo Zend_Json::fromXml($xml);