Example #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);
 }
Example #2
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;
 }
Example #3
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);
 }
Example #4
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;
 }
 public function __construct(callable $next, Negotiator $negotiator = null)
 {
     parent::__construct($next);
     $this->negotiator = $negotiator ?: new Negotiator();
 }
Example #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);
 }
Example #7
0
 public function __construct(callable $next, Geocoder $geocoder = null)
 {
     parent::__construct($next);
     $this->geocoder = $geocoder ?: $this->createDefaultGeocoder();
 }