/** * Get target of the current request. * * @return string request target */ public function getRequestTarget() { if ($this->requestTarget === null) { // Workaround for some servers (IIS) which do not provide // $_SERVER['REQUEST_URI']. Taken from // http://php.net/manual/en/reserved.variables.server.php#108186 if (!isset($_SERVER['REQUEST_URI'])) { $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME']; if (isset($_SERVER['QUERY_STRING'])) { $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; } } if (strpos($_SERVER['REQUEST_URI'], '?') === false) { $this->requestTarget = $_SERVER['REQUEST_URI']; } else { $parts = explode('?', $_SERVER['REQUEST_URI']); $this->requestTarget = $parts[0]; } // Use rawurldecode() so that +'s are not converted to spaces. $this->requestTarget = rawurldecode($this->requestTarget); if ($this->encodingConverter != null) { $this->requestTarget = $this->encodingConverter->decodeClientUrlData($this->requestTarget); } } return $this->requestTarget; }