From 9e63501237d10f4b12d4f41a8259a3d4fb870b1b Mon Sep 17 00:00:00 2001 From: Evan Seguin Date: Tue, 7 Aug 2012 16:07:20 -0700 Subject: [PATCH] removed unnecessary parameters from query string --- main/mashape/http/HttpClient.php | 2 -- main/mashape/http/UrlUtils.php | 5 ++--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/main/mashape/http/HttpClient.php b/main/mashape/http/HttpClient.php index b0f5601..56cdd0f 100755 --- a/main/mashape/http/HttpClient.php +++ b/main/mashape/http/HttpClient.php @@ -86,11 +86,9 @@ class HttpClient { //$url = self::removeQueryString($url); $data = http_build_query($parameters); } - $ch = curl_init (); // prepare the request - //curl_setopt($ch, CURLOPT_USERPWD, "username:password"); for basic auth curl_setopt ($ch, CURLOPT_URL , $url); if ($httpMethod != HttpMethod::GET) { curl_setopt ($ch, CURLOPT_CUSTOMREQUEST, $httpMethod); diff --git a/main/mashape/http/UrlUtils.php b/main/mashape/http/UrlUtils.php index 1f8c391..74ee5f6 100755 --- a/main/mashape/http/UrlUtils.php +++ b/main/mashape/http/UrlUtils.php @@ -53,6 +53,7 @@ class UrlUtils { if (array_key_exists($key, $parameters)) { $finalUrl = preg_replace("/(\?.+)\{" . $key . "\}/", '${1}' . urlencode($parameters[$key]), $finalUrl); $finalUrl = preg_replace("/\{" . $key . "\}/", rawurlencode($parameters[$key]), $finalUrl); + unset($parameters[$key]); } else { $finalUrl = preg_replace("/&?[\w]*=?\{" . $key . "\}/", "", $finalUrl); } @@ -68,9 +69,7 @@ class UrlUtils { } else { foreach ($parameters as $paramKey => $paramValue) { $delimiter = (strpos($finalUrl, "?") === false) ? "?" : "&"; - if (strpos($finalUrl, $paramKey."=") === false) { - $finalUrl .= $delimiter . $paramKey . "=" . urlencode($paramValue); - } + $finalUrl .= $delimiter . $paramKey . "=" . urlencode($paramValue); } }