renaming to unirest
This commit is contained in:
@@ -28,48 +28,26 @@ require_once(dirname(__FILE__) . "/Chunked.php");
|
||||
require_once(dirname(__FILE__) . "/HttpResponse.php");
|
||||
require_once(dirname(__FILE__) . "/HttpMethod.php");
|
||||
|
||||
class Unicorn {
|
||||
|
||||
// Use it like: Unicorn::getCallbackFunction(func_get_args());
|
||||
/*
|
||||
private static function getCallbackFunction($arg_list) {
|
||||
$argCount = count($arg_list);
|
||||
if ($argCount > 1) {
|
||||
$lastArgument = $arg_list[$argCount - 1];
|
||||
if (is_callable($lastArgument)) {
|
||||
return $lastArgument;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
private static function doAsync($operation, $callback) {
|
||||
require_once(dirname(__FILE__) . "/Thread.php");
|
||||
$id = ThreadStore::add(Unicorn::random(), $operation, $callback);
|
||||
$thread = new UnicornThread($id);
|
||||
$thread->start();
|
||||
return $thread;
|
||||
}
|
||||
*/
|
||||
class Unirest {
|
||||
|
||||
public static function get($url, $headers = array()) {
|
||||
return Unicorn::request(HttpMethod::GET, $url, NULL, $headers);
|
||||
return Unirest::request(HttpMethod::GET, $url, NULL, $headers);
|
||||
}
|
||||
|
||||
public static function post($url, $headers = array(), $body = NULL) {
|
||||
return Unicorn::request(HttpMethod::POST, $url, $body, $headers);
|
||||
return Unirest::request(HttpMethod::POST, $url, $body, $headers);
|
||||
}
|
||||
|
||||
public static function delete($url, $headers = array()) {
|
||||
return Unicorn::request(HttpMethod::DELETE, $url, NULL, $headers);
|
||||
return Unirest::request(HttpMethod::DELETE, $url, NULL, $headers);
|
||||
}
|
||||
|
||||
public static function put($url, $headers = array(), $body = NULL) {
|
||||
return Unicorn::request(HttpMethod::PUT, $url, $body, $headers);
|
||||
return Unirest::request(HttpMethod::PUT, $url, $body, $headers);
|
||||
}
|
||||
|
||||
public static function patch($url, $headers = array(), $body = NULL) {
|
||||
return Unicorn::request(HttpMethod::PATCH, $url, $body, $headers);
|
||||
return Unirest::request(HttpMethod::PATCH, $url, $body, $headers);
|
||||
}
|
||||
|
||||
private static function request($httpMethod, $url, $body = NULL, $headers = array()) {
|
||||
@@ -79,7 +57,7 @@ class Unicorn {
|
||||
if ($key == "user-agent" || key == "expect") continue;
|
||||
$lowercaseHeaders[] = $key . ": " . $val;
|
||||
}
|
||||
$lowercaseHeaders[] = "user-agent: unicorn-php/1.0";
|
||||
$lowercaseHeaders[] = "user-agent: unirest-php/1.0";
|
||||
$lowercaseHeaders[] = "expect:";
|
||||
|
||||
$ch = curl_init();
|
||||
@@ -88,7 +66,7 @@ class Unicorn {
|
||||
curl_setopt ($ch, CURLOPT_POSTFIELDS, $body);
|
||||
}
|
||||
|
||||
curl_setopt ($ch, CURLOPT_URL , Unicorn::encodeUrl($url));
|
||||
curl_setopt ($ch, CURLOPT_URL , Unirest::encodeUrl($url));
|
||||
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
curl_setopt ($ch, CURLOPT_MAXREDIRS, 10);
|
||||
Reference in New Issue
Block a user