|
@@ -0,0 +1,30 @@
|
|
|
|
+<?php
|
|
|
|
+
|
|
|
|
+namespace WebserviceBundle\Utils;
|
|
|
|
+
|
|
|
|
+class HttpUtils
|
|
|
|
+{
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @param string $url
|
|
|
|
+ *
|
|
|
|
+ * @return string
|
|
|
|
+ */
|
|
|
|
+ public static function cleanUrl($url)
|
|
|
|
+ {
|
|
|
|
+ $parsed_url = parse_url($url);
|
|
|
|
+
|
|
|
|
+ $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';
|
|
|
|
+ $host = isset($parsed_url['host']) ? $parsed_url['host'] : '';
|
|
|
|
+ $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '';
|
|
|
|
+ $user = isset($parsed_url['user']) ? $parsed_url['user'] : '';
|
|
|
|
+ $pass = isset($parsed_url['pass']) ? ':' . $parsed_url['pass'] : '';
|
|
|
|
+ $pass = ($user || $pass) ? "$pass@" : '';
|
|
|
|
+ $path = isset($parsed_url['path']) ? '/' . implode('/', array_filter(explode('/', $parsed_url['path']))) : '';
|
|
|
|
+ $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : '';
|
|
|
|
+ $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : '';
|
|
|
|
+
|
|
|
|
+ return "$scheme$user$pass$host$port$path$query$fragment";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|