X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Finstaclick%2Fphp-webdriver%2Flib%2FWebDriver%2FService%2FCurlService.php;fp=vendor%2Finstaclick%2Fphp-webdriver%2Flib%2FWebDriver%2FService%2FCurlService.php;h=0000000000000000000000000000000000000000;hp=99af82ed8b8398aeb05ccdf14fce8a7c3299132c;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/vendor/instaclick/php-webdriver/lib/WebDriver/Service/CurlService.php b/vendor/instaclick/php-webdriver/lib/WebDriver/Service/CurlService.php deleted file mode 100755 index 99af82ed8..000000000 --- a/vendor/instaclick/php-webdriver/lib/WebDriver/Service/CurlService.php +++ /dev/null @@ -1,122 +0,0 @@ - - * @author Anthon Pang - * @author Fabrizio Branca - */ - -namespace WebDriver\Service; - -use WebDriver\Exception as WebDriverException; - -/** - * WebDriver\Service\CurlService class - * - * @package WebDriver - */ -class CurlService implements CurlServiceInterface -{ - /** - * {@inheritdoc} - */ - public function execute($requestMethod, $url, $parameters = null, $extraOptions = array()) - { - $customHeaders = array( - 'Content-Type: application/json;charset=UTF-8', - 'Accept: application/json;charset=UTF-8', - ); - - $curl = curl_init($url); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); - - switch ($requestMethod) { - case 'GET': - break; - - case 'POST': - if ($parameters && is_array($parameters)) { - curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($parameters)); - } else { - $customHeaders[] = 'Content-Length: 0'; - } - - // Suppress "Expect: 100-continue" header automatically added by cURL that - // causes a 1 second delay if the remote server does not support Expect. - $customHeaders[] = 'Expect:'; - - curl_setopt($curl, CURLOPT_POST, true); - break; - - case 'DELETE': - curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'DELETE'); - break; - - case 'PUT': - if ($parameters && is_array($parameters)) { - curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($parameters)); - } else { - $customHeaders[] = 'Content-Length: 0'; - } - - // Suppress "Expect: 100-continue" header automatically added by cURL that - // causes a 1 second delay if the remote server does not support Expect. - $customHeaders[] = 'Expect:'; - - curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT'); - break; - } - - foreach ($extraOptions as $option => $value) { - curl_setopt($curl, $option, $value); - } - - curl_setopt($curl, CURLOPT_HTTPHEADER, $customHeaders); - - $rawResult = trim(curl_exec($curl)); - - $info = curl_getinfo($curl); - $info['request_method'] = $requestMethod; - - if (array_key_exists(CURLOPT_FAILONERROR, $extraOptions) && - $extraOptions[CURLOPT_FAILONERROR] && - CURLE_GOT_NOTHING !== ($errno = curl_errno($curl)) && - $error = curl_error($curl) - ) { - curl_close($curl); - - throw WebDriverException::factory( - WebDriverException::CURL_EXEC, - sprintf( - "Curl error thrown for http %s to %s%s\n\n%s", - $requestMethod, - $url, - $parameters && is_array($parameters) ? ' with params: ' . json_encode($parameters) : '', - $error - ), - $errno, - null, - $info - ); - } - - curl_close($curl); - - return array($rawResult, $info); - } -}