예제 #1
0
파일: Output.php 프로젝트: Rud5G/frapi
 /**
  * Send HTTP headers, namely HTTP Status Code.
  * We need the unformatted content to determine
  * what headers to send.
  *
  * @param Mixed $response
  *
  * @return Object $this
  **/
 public function sendHeaders($response)
 {
     header('HTTP/1.1 ' . intval($response->getStatusCode()));
     if ($response instanceof Frapi_Response) {
         $content_type = $response->getContentType();
         if ($content_type) {
             $this->mimeType = $content_type;
         }
     }
     header('Content-type: ' . $this->mimeType . '; charset=utf-8');
     //IF debugging is turned on, then send cache info
     //headers - very useful for seeing what's happening.
     if (Frapi_Controller_Main::MAIN_WEBSERVICE_DEBUG) {
         $log = Frapi_Internal::getLog();
         $cache_info = 'Cache Fetches(' . $log['cache-get']['times'] . ') ' . 'Cache Stores(' . $log['cache-set']['times'] . ') ' . 'DbHandles(' . $log['db']['times'] . ')';
         header('X-Cache-Info: ' . $cache_info);
         if (!empty($log['cache-get']['keys'])) {
             sort($log['cache-get']['keys']);
             header('X-Cache-Lookups: ' . implode(' ', $log['cache-get']['keys']));
         }
         if (!empty($log['cache-set']['keys'])) {
             sort($log['cache-set']['keys']);
             header('X-Cache-Stores: ' . implode(' ', $log['cache-set']['keys']));
         }
     }
     $cache = new Frapi_Internal();
     $cache = $cache->getCachedDbConfig();
     $allowCrossDomain = isset($cache['allow_cross_domain']) ? $cache['allow_cross_domain'] : false;
     if ($allowCrossDomain) {
         header('Access-Control-Allow-Origin: *');
         header('Access-Control-Allow-Headers: *');
         header('Access-Control-Allow-Credentials: true');
         header('Access-Control-Allow-Methods: POST,GET,PUT,DELETE,HEAD');
         header('Access-Control-Max-Age: 604800');
     }
     return $this;
 }
예제 #2
0
파일: Output.php 프로젝트: reith2004/frapi
    /**
     * Send HTTP headers, namely HTTP Status Code.
     * We need the unformatted content to determine
     * what headers to send.
     *
     * @param Mixed $response
     *
     * @return Object $this
     **/
    public function sendHeaders($response)
    {
        header('HTTP/1.1 '.intval($response->getStatusCode()));

        if ($response instanceof Frapi_Response) {
            $content_type = $response->getContentType();
            if ($content_type) {
                $this->mimeType = $content_type;
            }
        }

        header('Content-type: '.$this->mimeType.'; charset=utf-8');

        //IF debugging is turned on, then send cache info
        //headers - very useful for seeing what's happening.
        if (Frapi_Controller_Main::MAIN_WEBSERVICE_DEBUG) {
            $log = Frapi_Internal::getLog();

            $cache_info = 'Cache Fetches(' . $log['cache-get']['times'] . ') ' .
                          'Cache Stores(' . $log['cache-set']['times'] . ') ' .
                          'DbHandles(' . $log['db']['times'] . ')';

            header('X-Cache-Info: '.$cache_info);

            if (!empty($log['cache-get']['keys'])) {
                sort($log['cache-get']['keys']);
                header('X-Cache-Lookups: '.implode(' ', $log['cache-get']['keys']));
            }

            if (!empty($log['cache-set']['keys'])) {
                sort($log['cache-set']['keys']);
                header('X-Cache-Stores: '.implode(' ', $log['cache-set']['keys']));
            }
        }

        return $this;
    }