Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.758 diff -u -r1.758 common.inc --- includes/common.inc 18 Feb 2008 16:53:36 -0000 1.758 +++ includes/common.inc 20 Feb 2008 01:32:06 -0000 @@ -439,7 +439,14 @@ case 'http': $port = isset($uri['port']) ? $uri['port'] : 80; $host = $uri['host'] . ($port != 80 ? ':'. $port : ''); - $fp = @fsockopen($uri['host'], $port, $errno, $errstr, 15); + if (variable_get('proxy_server', '') != '') { + $proxy_server = variable_get('proxy_server', ''); + $proxy_port = variable_get('proxy_port', 8080); + $fp = @fsockopen($proxy_server, $proxy_port, $errno, $errstr, 15); + } + else { + $fp = @fsockopen($uri['host'], $port, $errno, $errstr, 15); + } break; case 'https': // Note: Only works for PHP 4.3 compiled with OpenSSL. @@ -462,9 +469,14 @@ } // Construct the path to act on. - $path = isset($uri['path']) ? $uri['path'] : '/'; - if (isset($uri['query'])) { - $path .= '?'. $uri['query']; + if (variable_get('proxy_server', '') != '') { + $path = $url; + } + else { + $path = isset($uri['path']) ? $uri['path'] : '/'; + if (isset($uri['query'])) { + $path .= '?'. $uri['query']; + } } // Create HTTP request. @@ -482,6 +494,14 @@ $defaults['Authorization'] = 'Authorization: Basic '. base64_encode($uri['user'] . (!empty($uri['pass']) ? ":". $uri['pass'] : '')); } + // If the proxy server required a username then attempt to authenticate with it + if (variable_get('proxy_username', '') != '') { + $username = variable_get('proxy_username', ''); + $password = variable_get('proxy_password', ''); + $auth_string = base64_encode($username . ($password != '' ? ':'. $password ? '')); + $defaults['Proxy-Authorization'] = 'Proxy-Authorization: Basic '. $auth_string ."\r\n"; + } + foreach ($headers as $header => $value) { $defaults[$header] = $header .': '. $value; }