示例#1
0
 public function __construct($curlHandle, $path, $accept, array $params = NULL)
 {
     parent::__construct($curlHandle, $path, $accept, $params);
     $this->httpMethod = "HEAD";
     curl_setopt($curlHandle, CURLOPT_CUSTOMREQUEST, $this->httpMethod);
     curl_setopt($curlHandle, CURLOPT_NOBODY, TRUE);
 }
示例#2
0
 /**
  * Constructor
  *
  * @param ObjectConfig|null $config  An optional ObjectConfig object with configuration options
  * @return HttpResponse
  */
 public function __construct(ObjectConfig $config)
 {
     parent::__construct($config);
     //Set query parameters
     $this->setQuery($config->query);
     //Set data parameters
     $this->setData($config->data);
 }
示例#3
0
 /**
  * Constructor
  *
  * @param ObjectConfig|null $config  An optional ObjectConfig object with configuration options
  */
 public function __construct(ObjectConfig $config)
 {
     parent::__construct($config);
     // Set the user identifier
     $this->_user = $config->user;
     //Set query parameters
     $this->setQuery($config->query);
     //Set data parameters
     $this->setData($config->data);
     //Set the format
     $this->setFormat($config->format);
 }
示例#4
0
 function __construct($app_id, $app_key, $app_secret)
 {
     //put the FB API keys here:
     $this->fb_id = $app_id;
     $this->fb_key = $app_key;
     $this->fb_secret = $app_secret;
     //call parent constructor
     parent::__construct();
     //set up the specifics for connecting to facebook's api
     $this->request_params['port'] = 443;
     $this->request_params['scheme'] = 'tls://';
     $this->request_params['host'] = $this->fb_d;
 }
示例#5
0
 public function __construct($curlHandle, $path, $accept, array $params = NULL)
 {
     parent::__construct($curlHandle, $path, $accept, NULL);
     $this->httpMethod = "DELETE";
     $this->contentType = parent::URLENCODED;
     $this->path = $path;
     $this->curlHandle = $curlHandle;
     $this->accept = $accept;
     // set the http method
     curl_setopt($curlHandle, CURLOPT_CUSTOMREQUEST, $this->httpMethod);
     if ($params != NULL) {
         $this->body = http_build_query($params);
         curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $this->body);
     }
 }
 public function __construct($url, $requestMethod = HTTP_METH_GET, array $options = array())
 {
     static $proxyOptions = array(), $hasProxyOptions = false;
     // Proxy settings from site.ini
     if (!$hasProxyOptions) {
         $ini = eZINI::instance();
         $proxyServer = $ini->hasVariable('ProxySettings', 'ProxyServer') ? $ini->variable('ProxySettings', 'ProxyServer') : false;
         if ($proxyServer) {
             $proxyServerParts = parse_url($proxyServer);
             $proxyOptions['proxyhost'] = $proxyServerParts['host'];
             $proxyOptions['proxyport'] = $proxyServerParts['port'];
             $proxyOptions['proxytype'] = HTTP_PROXY_HTTP;
             $proxyUsername = $ini->hasVariable('ProxySettings', 'User') ? $ini->variable('ProxySettings', 'User') : false;
             $proxyPassword = $ini->hasVariable('ProxySettings', 'Password') ? $ini->variable('ProxySettings', 'Password') : false;
             if ($proxyUsername) {
                 $proxyOptions['proxyauth'] = "{$proxyUsername}:{$proxyPassword}";
             }
         }
         $hasProxyOptions = true;
     }
     parent::__construct($url, $requestMethod, $options + $proxyOptions);
 }
示例#7
0
文件: P2HttpExt.php 项目: poppen/p2
 /**
  * コンストラクタ
  *
  * @param string $url
  * @param string $destination
  * @param array $options
  * @param P2HttpCallback $onSuccess
  * @param P2HttpCallback $onFailure
  */
 public function __construct($url, $destination, array $options = null, P2HttpCallback $onSuccess = null, P2HttpCallback $onFailure = null)
 {
     global $_conf;
     if ($options === null) {
         $options = array();
     }
     if (!isset($options['connecttimeout'])) {
         $options['connecttimeout'] = $_conf['fsockopen_time_limit'];
     }
     if (!isset($options['timeout'])) {
         $options['timeout'] = $_conf['fsockopen_time_limit'] * 2;
     }
     if (!isset($options['compress'])) {
         $options['compress'] = true;
     }
     if (!isset($options['useragent'])) {
         $options['useragent'] = P2Util::getP2UA($withMonazilla = true);
     }
     if ($_conf['proxy_use'] && !isset($options['proxyhost']) && !empty($_conf['proxy_host'])) {
         $options['proxyhost'] = $_conf['proxy_host'];
         if (!empty($_conf['proxy_port']) && is_numeric($_conf['proxy_port'])) {
             $options['proxyport'] = (int) $_conf['proxy_port'];
         } elseif (strpos($_conf['proxy_host'], ':') === false) {
             $options['proxyport'] = 80;
         }
         /*
         $options['proxytype'] = HTTP_PROXY_HTTP;
         if (isset($_conf['proxy_type'])) {
             switch ($_conf['proxy_type']) {
             case 'http':   $options['proxytype'] = HTTP_PROXY_HTTP;   break;
             case 'socks4': $options['proxytype'] = HTTP_PROXY_SOCKS4; break;
             case 'socks5': $options['proxytype'] = HTTP_PROXY_SOCKS5; break;
             default:
                 if (is_numeric($options['proxytype'])) {
                     $options['proxytype'] = (int)$_conf['proxy_type'];
                 }
             }
         }
         
         if (!empty($_conf['proxy_auth'])) {
             $options['proxy_auth'] = $_conf['proxy_auth'];
             $options['proxyauthtype'] = HTTP_AUTH_BASIC;
             if (isset($_conf['proxy_auth_type'])) {
                 switch ($_conf['proxy_auth_type']) {
                 case 'basic':  $options['proxyauthtype'] = HTTP_AUTH_BASIC;  break;
                 case 'digest': $options['proxyauthtype'] = HTTP_AUTH_DIGEST; break;
                 case 'ntlm':   $options['proxyauthtype'] = HTTP_AUTH_NTLM;   break;
                 case 'gssneg': $options['proxyauthtype'] = HTTP_AUTH_GSSNEG; break;
                 case 'any':    $options['proxyauthtype'] = HTTP_AUTH_ANY;    break;
                 default:
                     if (is_numeric($options['proxytype'])) {
                         $options['proxyauthtype'] = (int)$_conf['proxy_auth_type'];
                     }
                 }
             }
         }
         */
     }
     if (!isset($options['lastmodified']) && file_exists($destination)) {
         $options['lastmodified'] = filemtime($destination);
     } else {
         FileCtl::mkdir_for($destination);
     }
     $this->_destination = $destination;
     $this->_permission = !empty($_conf['dl_perm']) ? $_conf['dl_perm'] : 0666;
     $this->_errorCode = self::E_NONE;
     $this->_errorInfo = '';
     $this->_onSuccess = $onSuccess;
     $this->_onFailure = $onFailure;
     $this->_next = null;
     parent::__construct($url, HttpRequest::METH_GET, $options);
 }