/** * Test URIs if SERVER[REQUEST_URI] is not available (ie. IIS) */ public function testUrisIfNoRequestUri() { unset($_SERVER['REQUEST_URI']); //With htaccess $_SERVER['PHP_SELF'] = '/foo/one/two'; $_SERVER['SCRIPT_NAME'] = '/foo/bootstrap.php'; $this->assertEquals('/foo', Slim_Http_Uri::getBaseUri(true)); $this->assertEquals('/one/two', Slim_Http_Uri::getUri(true)); //Without htaccess $_SERVER['PHP_SELF'] = '/foo/bootstrap.php/one/two'; $_SERVER['SCRIPT_NAME'] = '/foo/bootstrap.php'; $this->assertEquals('/foo/bootstrap.php', Slim_Http_Uri::getBaseUri(true)); $this->assertEquals('/one/two', Slim_Http_Uri::getUri(true)); }
/** * Constructor */ public function __construct() { $this->method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : false; $this->headers = $this->loadHttpHeaders(); $this->body = @file_get_contents('php://input'); $this->get = self::stripSlashesIfMagicQuotes($_GET); $this->post = self::stripSlashesIfMagicQuotes($_POST); $this->put = self::stripSlashesIfMagicQuotes($this->loadPutParameters()); $this->cookies = self::stripSlashesIfMagicQuotes($_COOKIE); $this->root = Slim_Http_Uri::getBaseUri(true); $this->resource = Slim_Http_Uri::getUri(true); $this->checkForHttpMethodOverride(); }
/** * Test URI if no information source available */ public function testUriWithoutDataSource() { unset($_SERVER['PATH_INFO']); unset($_SERVER['REQUEST_URI']); unset($_SERVER['PHP_SELF']); try { $uri = Slim_Http_Uri::getUri(true); $this->fail('Did not catch RuntimeException when determining URI without a data source'); } catch (RuntimeException $e) { } }