From 87a3d734dc30765d95e83064cd3f04a4878a0aa2 Mon Sep 17 00:00:00 2001 From: prasad83 Date: Fri, 18 May 2018 18:45:41 +0530 Subject: [PATCH 1/2] Apply encodeUrl only when data is passed. Query part can be constructed in the following manner into the URL: * $url . '?' . http_build_query($data); /* uses PHP_QUERY_RFC1738 */ * $url . '?' . http_build_query($data, null, ini_get('arg_separator.output'), PHP_QUERY_RFC3986); So when no $data is set - incoming $url should be assumed pre-built as required. --- src/Unirest/Request.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Unirest/Request.php b/src/Unirest/Request.php index b49780d..589a4a6 100755 --- a/src/Unirest/Request.php +++ b/src/Unirest/Request.php @@ -417,7 +417,7 @@ public static function send($method, $url, $body = null, $headers = array(), $us } $curl_base_options = [ - CURLOPT_URL => self::encodeUrl($url), + CURLOPT_URL => $data ? self::encodeUrl($url) : $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_MAXREDIRS => 10, From ea0543f55fface2f3c560e0e0955d8280b3d3f0a Mon Sep 17 00:00:00 2001 From: prasad83 Date: Fri, 18 May 2018 18:55:35 +0530 Subject: [PATCH 2/2] Fixed typo (body) instead of (data) --- src/Unirest/Request.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Unirest/Request.php b/src/Unirest/Request.php index 589a4a6..1b3e316 100755 --- a/src/Unirest/Request.php +++ b/src/Unirest/Request.php @@ -417,7 +417,7 @@ public static function send($method, $url, $body = null, $headers = array(), $us } $curl_base_options = [ - CURLOPT_URL => $data ? self::encodeUrl($url) : $url, + CURLOPT_URL => $body ? self::encodeUrl($url) : $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_MAXREDIRS => 10,