*/
class Client
{
+ const USE_CURL_NEVER = 0;
+ const USE_CURL_ALWAYS = 1;
+ const USE_CURL_AUTO = 2;
+
/// @todo: do these need to be public?
public $method = 'http';
public $server;
public $cookies = array();
public $extracurlopts = array();
+ public $use_curl = self::USE_CURL_AUTO;
/**
* @var bool
*/
public $request_compression = '';
+
/**
* CURL handle: used for keep-alive connections (PHP 4.3.8 up, see:
* http://curl.haxx.se/docs/faq.html#7.3).
$this->accepted_charset_encodings = array('UTF-8', 'ISO-8859-1', 'US-ASCII');
// Add all charsets which mbstring can handle, but remove junk not found in IANA registry at
- // in http://www.iana.org/assignments/character-sets/character-sets.xhtml
+ // http://www.iana.org/assignments/character-sets/character-sets.xhtml
// NB: this is disabled to avoid making all the requests sent huge... mbstring supports more than 80 charsets!
/*if (function_exists('mb_list_encodings')) {
* This option can be very useful when debugging servers as it allows you to see exactly what the client sends and
* the server returns.
*
- * @param integer $in values 0, 1 and 2 are supported (2 = echo sent msg too, before received response)
+ * @param integer $level values 0, 1 and 2 are supported (2 = echo sent msg too, before received response)
*/
public function setDebug($level)
{
$this->extracurlopts = $options;
}
+ /**
+ * @param int $useCurlMode self::USE_CURL_ALWAYS, self::USE_CURL_AUTO or self::USE_CURL_NEVER
+ */
+ public function setUseCurl($useCurlMode)
+ {
+ $this->use_curl = $useCurlMode;
+ }
+
+
/**
* Set user-agent string that will be used by this client instance in http headers sent to the server.
*
$req->setDebug($this->debug);
/// @todo we could be smarter about this and force usage of curl in scenarios where it is both available and
- /// needed, such as digest or ntlm auth
- $useCurl = ($method == 'https' || $method == 'http11');
+ /// needed, such as digest or ntlm auth. Do not attempt to use it for https if not present
+ $useCurl = ($this->use_curl == self::USE_CURL_ALWAYS) || ($this->use_curl == self::USE_CURL_AUTO &&
+ ($method == 'https' || $method == 'http11'));
if ($useCurl) {
$r = $this->sendPayloadCURL(