Exemplo n.º 1
0
 /**
  * Cleans the output buffer and builds a default HTTP 200 OK "Allow" response to an OPTIONS request.
  */
 private function prepareOptionsResponse()
 {
     ob_clean();
     // Determine which options have been set up for this route based on the registered routes
     $optionsForRoute = $this->router->getOptions($this->request);
     $methodsAllowed = [RequestMethod::OPTIONS];
     foreach ($optionsForRoute as $route) {
         // Extend the set of acceptable methods with the ones set up for this route
         $acceptableMethods = $route->getAcceptableMethods();
         $methodsAllowed = array_merge_recursive($methodsAllowed, $acceptableMethods);
     }
     array_unique($methodsAllowed);
     $this->response = new Response();
     $this->response->setResponseCode(ResponseCode::HTTP_OK);
     $this->response->setHeader('Allow', implode(',', $methodsAllowed));
     $this->response->setBody('');
     $this->context->registerInstance($this->response);
     $this->finalizeOutputBuffer();
 }