Check if $body is traversable before recursively sanitizing (allows for raw JSON body)

Add testRawPost()
This commit is contained in:
Sam Sullivan
2014-01-13 23:21:04 -06:00
parent f5fee2dc46
commit 646e24aefe
2 changed files with 20 additions and 3 deletions

View File

@@ -171,9 +171,13 @@
$ch = curl_init();
if ($httpMethod != HttpMethod::GET) {
curl_setopt ($ch, CURLOPT_CUSTOMREQUEST, $httpMethod);
Unirest::http_build_query_for_curl($body, $postBody);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postBody);
curl_setopt ($ch, CURLOPT_CUSTOMREQUEST, $httpMethod);
if( is_array($body) || $body instanceof Traversable ) {
Unirest::http_build_query_for_curl($body, $postBody);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postBody);
} else {
curl_setopt ($ch, CURLOPT_POSTFIELDS, $body);
}
} else if (is_array($body)) {
if (strpos($url,'?') !== false) {
$url .= "&";