|
@@ -268,6 +268,39 @@ class Request
|
|
|
return $this->requestUri;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Generates a normalized URI for the Request.
|
|
|
+ *
|
|
|
+ * It builds a normalized query string, where keys/value pairs are alphabetized
|
|
|
+ * and have consistent escaping.
|
|
|
+ *
|
|
|
+ * @return string A normalized URI for the Request
|
|
|
+ */
|
|
|
+ public function getUri()
|
|
|
+ {
|
|
|
+ $parts = $this->getScheme().'://'.$this->getHost().':'.$this->getPort().$this->getScriptName().$this->getPathInfo();
|
|
|
+
|
|
|
+ if ($qs = $this->server->get('QUERY_STRING')) {
|
|
|
+ $parts = array();
|
|
|
+ foreach (explode('&', $qs) as $segment) {
|
|
|
+ $tmp = explode('=', urldecode($segment), 2);
|
|
|
+ $parts[urlencode($tmp[0])] = urlencode($tmp[1]);
|
|
|
+ }
|
|
|
+ ksort($parts);
|
|
|
+
|
|
|
+ $elements = array();
|
|
|
+ foreach ($parts as $key => $value) {
|
|
|
+ $elements[] = "$key=$value";
|
|
|
+ }
|
|
|
+
|
|
|
+ if (count($elements)) {
|
|
|
+ $parts .= '?'.implode('&', $elements);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $parts;
|
|
|
+ }
|
|
|
+
|
|
|
public function isSecure()
|
|
|
{
|
|
|
return (
|