예제 #1
0
 public function call(array &$environment, array $response)
 {
     if (isset($environment['HTTP_X_HTTP_METHOD_OVERRIDE'])) {
         $environment['REQUEST_METHOD'] = $environment['HTTP_X_HTTP_METHOD_OVERRIDE'];
     }
     return parent::call($environment, $response);
 }
예제 #2
0
 public function call(array &$environment, array $response)
 {
     $accept = isset($environment['HTTP_ACCEPT']) ? $environment['HTTP_ACCEPT'] : '';
     $priorities = isset($environment['negotiation.priorities']) ? $environment['negotiation.priorities'] : array();
     $environment['request.best_format'] = $this->negotiator->getBest($accept, $priorities);
     return parent::call($environment, $response);
 }
예제 #3
0
 public function call(array &$environment, array $response)
 {
     try {
         return parent::call($environment, $response);
     } catch (Exception $e) {
         if (isset($this->options['throw'])) {
             throw $e;
         }
     }
     return $response;
 }
예제 #4
0
 public function call(array &$environment, array $response)
 {
     if ($environment['REQUEST_METHOD'] == 'HEAD') {
         // FIXME: return callback to the app so that we can remove the
         // response body
         $response = parent::call($environment, $response);
         // Clean up the response body
         $response[2] = '';
         return $response;
     }
     return parent::call($environment, $response);
 }
예제 #5
0
 public function call(array &$environment, array $response)
 {
     $namespace = $this->options['prefix'];
     if (isset($environment['PATH_INFO'])) {
         $namespace .= $environment['PATH_INFO'];
     } else {
         if (isset($environment['REQUEST_URI'])) {
             $namespace .= $environment['REQUEST_URI'];
         }
     }
     $namespace = preg_replace('#[^\\w]+#', '_', $namespace);
     xhprof_enable($this->options['flags']);
     $response = parent::call($environment, $response);
     $profile = xhprof_disable();
     $runs = new XHProfRuns_Default($this->options['output_dir']);
     $this->runId = $runs->save_run($profile, $namespace);
     return $response;
 }
예제 #6
0
 public function call(array &$environment, array $response)
 {
     if (!$this->cors->isCorsRequest($environment)) {
         return parent::call($environment, $response);
     }
     if ($this->cors->isPreflightRequest($environment)) {
         return $this->cors->handlePreflightRequest($environment);
     }
     if (!$this->cors->isActualRequestAllowed($environment)) {
         return [403, [], 'Not allowed'];
     }
     $response = parent::call($environment, $response);
     return $this->cors->addActualRequestHeaders($environment, $response);
 }
예제 #7
0
 public function __construct(callable $next, Geocoder $geocoder = null)
 {
     parent::__construct($next);
     $this->geocoder = $geocoder ?: $this->createDefaultGeocoder();
 }