Beispiel #1
0
 /**
  * @runInSeparateProcess
  */
 public function testSendHeaders()
 {
     if (!function_exists('xdebug_get_headers')) {
         $this->markTestSkipped('xdebug is not installed');
     }
     $response = new Response();
     $response->setResponseCode(ResponseCode::HTTP_BAD_GATEWAY);
     $response->setHeader('X-Check-Out', 'http://www.google.com');
     $this->expectOutputString('');
     $response->send();
     $headers = xdebug_get_headers();
     $this->assertContains('X-Check-Out: http://www.google.com', $headers, '', true);
     $this->assertEquals($response->getResponseCode(), http_response_code());
 }
Beispiel #2
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();
 }