/** * Constructs a new Request object based on the given environment data. * * @param array $get Data similar to that which is typically provided by $_GET * @param array $post Data similar to that which is typically provided by $_POST * @param array $files Data similar to that which is typically provided by $_FILES * @param array $server Data similar to that which is typically provided by $_SERVER * @see create() * @see createFromEnvironment() * @api */ public function __construct(array $get, array $post, array $files, array $server) { $this->headers = Headers::createFromServer($server); $this->setMethod(isset($server['REQUEST_METHOD']) ? $server['REQUEST_METHOD'] : 'GET'); $protocol = isset($server['SSL_SESSION_ID']) || isset($server['HTTPS']) && ($server['HTTPS'] === 'on' || strcmp($server['HTTPS'], '1') === 0) ? 'https' : 'http'; $this->uri = new Uri($protocol . '://' . (isset($server['HTTP_HOST']) ? $server['HTTP_HOST'] : 'localhost') . str_replace('/index.php', '', isset($server['REQUEST_URI']) ? $server['REQUEST_URI'] : '/')); $this->server = $server; $this->arguments = $this->buildUnifiedArguments($get, $post, $files); }
/** * Removes the specified cookie from the headers of this message, if it exists * * This is a shortcut for $message->getHeaders()->removeCookie($name); * * @param string $name Name of the cookie to remove * @return void * @api */ public function removeCookie($name) { $this->headers->removeCookie($name); }
/** * @dataProvider cacheDirectivesAndExampleValues * @test */ public function getCacheControlDirectiveReturnsTheSpecifiedDirectiveValueIfPresent($name, $value) { $headers = new Headers(); $this->assertNull($headers->getCacheControlDirective($name)); if ($value === TRUE) { $headers->setCacheControlDirective($name); } else { $headers->setCacheControlDirective($name, $value); } $this->assertEquals($value, $headers->getCacheControlDirective($name)); }