Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php drupal 6上不支持代理的drupal_http_请求。。。如何做到这一点?_Php_Http_Drupal 6_Proxy - Fatal编程技术网

Php drupal 6上不支持代理的drupal_http_请求。。。如何做到这一点?

Php drupal 6上不支持代理的drupal_http_请求。。。如何做到这一点?,php,http,drupal-6,proxy,Php,Http,Drupal 6,Proxy,几天前我提出了一些代理服务器,但是drupal_http_请求不支持通过代理调用URL。有人有补丁或解决方案吗? (drupal 6)您可以使用代替。这将允许您使用。您可以使用代替。在Drupal 6中,Drupal\u http\u request()不支持代理,但在Drupal 7中通过以下代码支持代理 // Use a proxy if one is defined and the host is not on the excluded list. $proxy_server =

几天前我提出了一些代理服务器,但是drupal_http_请求不支持通过代理调用URL。有人有补丁或解决方案吗?
(drupal 6)

您可以使用代替。这将允许您使用。

您可以使用代替。在Drupal 6中,
Drupal\u http\u request()
不支持代理,但在Drupal 7中通过以下代码支持代理

  // Use a proxy if one is defined and the host is not on the excluded list.
  $proxy_server = variable_get('proxy_server', '');
  if ($proxy_server && _drupal_http_use_proxy($uri['host'])) {
    // Set the scheme so we open a socket to the proxy server.
    $uri['scheme'] = 'proxy';
    // Set the path to be the full URL.
    $uri['path'] = $url;
    // Since the URL is passed as the path, we won't use the parsed query.
    unset($uri['query']);

    // Add in username and password to Proxy-Authorization header if needed.
    if ($proxy_username = variable_get('proxy_username', '')) {
      $proxy_password = variable_get('proxy_password', '');
      $options['headers']['Proxy-Authorization'] = 'Basic ' . base64_encode($proxy_username . (!empty($proxy_password) ? ":" . $proxy_password : ''));
    }
    // Some proxies reject requests with any User-Agent headers, while others
    // require a specific one.
    $proxy_user_agent = variable_get('proxy_user_agent', '');
    // The default value matches neither condition.
    if ($proxy_user_agent === NULL) {
      unset($options['headers']['User-Agent']);
    }
    elseif ($proxy_user_agent) {
      $options['headers']['User-Agent'] = $proxy_user_agent;
    }
  }
使用cUrl的另一种方法是执行类似于以下代码的代码

$headers = array(
  // The user agent to use for the proxy, or NULL.
  'User-Agent' => $proxy_user_agent,

  // The host to call.
  'Host' => $host,

  // Use this only if required.
  'Proxy-Authorization' => 'Basic ' . base64_encode($proxy_username . (!empty($proxy_password) ? ":" . $proxy_password : '')),
);

$result = drupal_http_request($proxy_url, $headers, $method, $data);

在Drupal 6中,
Drupal\u http\u request()
不支持代理,但在Drupal 7中,它通过以下代码支持代理

  // Use a proxy if one is defined and the host is not on the excluded list.
  $proxy_server = variable_get('proxy_server', '');
  if ($proxy_server && _drupal_http_use_proxy($uri['host'])) {
    // Set the scheme so we open a socket to the proxy server.
    $uri['scheme'] = 'proxy';
    // Set the path to be the full URL.
    $uri['path'] = $url;
    // Since the URL is passed as the path, we won't use the parsed query.
    unset($uri['query']);

    // Add in username and password to Proxy-Authorization header if needed.
    if ($proxy_username = variable_get('proxy_username', '')) {
      $proxy_password = variable_get('proxy_password', '');
      $options['headers']['Proxy-Authorization'] = 'Basic ' . base64_encode($proxy_username . (!empty($proxy_password) ? ":" . $proxy_password : ''));
    }
    // Some proxies reject requests with any User-Agent headers, while others
    // require a specific one.
    $proxy_user_agent = variable_get('proxy_user_agent', '');
    // The default value matches neither condition.
    if ($proxy_user_agent === NULL) {
      unset($options['headers']['User-Agent']);
    }
    elseif ($proxy_user_agent) {
      $options['headers']['User-Agent'] = $proxy_user_agent;
    }
  }
使用cUrl的另一种方法是执行类似于以下代码的代码

$headers = array(
  // The user agent to use for the proxy, or NULL.
  'User-Agent' => $proxy_user_agent,

  // The host to call.
  'Host' => $host,

  // Use this only if required.
  'Proxy-Authorization' => 'Basic ' . base64_encode($proxy_username . (!empty($proxy_password) ? ":" . $proxy_password : '')),
);

$result = drupal_http_request($proxy_url, $headers, $method, $data);