The documentation shows that proxy exceptions should be declared as array-values:

$conf['http_proxy'] = array(
  'server' => 'your.proxy.com',
  'port' => '8080',
  'username' => 'user',
  'password' => 'pass',
  'exceptions' => array('localhost'),
);

However, they're currently tested as array keys:

array_key_exists($uri['host'], $proxy['exceptions'])

So proxy exceptions are currently ignored, if configured according to the documentation.

CommentFileSizeAuthor
#1 1802076-chr-fix_proxy_exceptions.patch585 bytesmanarth

Comments

manarth’s picture

Status: Active » Needs review
StatusFileSize
new585 bytes

Patch changes the exception-lookup to use `in_array` instead of `array_key_exists`.

minoroffense’s picture

Should this instead be a documentation change and not a code change? Otherwise we may create a bug in some implementations.

Nope. Code change.

minoroffense’s picture

Status: Needs review » Patch (to be ported)

Changed in 7.x-1.x

drasgardian’s picture

Status: Patch (to be ported) » Reviewed & tested by the community

Doesn't look like this has been committed.

minoroffense’s picture

Version: 7.x-1.5 » 7.x-1.x-dev

Oops must have crushed the change when fixing other bugs. I'll restore it.

minoroffense’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Alright, now it's in 7.x-1.x

minoroffense’s picture

Version: 6.x-1.x-dev » 8.x-1.x-dev
Priority: Normal » Minor
clertem’s picture

Issue summary: View changes

Well funny that no-one has raised this before, but matching the hostname with each entry in the exceptions array on equality is not really how we use proxy exceptions. Should we not do wildcard matching instead ?
In other terms, if 'proxy_exceptions' = [ '*.mycompany.com' ] then a request made to 'myserver.mycompany.com' would bypass the proxy.

manarth’s picture

I can see the benefit of a wildcard-based proxy-exception system, but drupal core's proxy exceptions currently require full URLs:

/**
 * Helper function for determining hosts excluded from needing a proxy.
 *
 * @return
 *   TRUE if a proxy should be used for this host.
 */
function _drupal_http_use_proxy($host) {
  $proxy_exceptions = variable_get('proxy_exceptions', array('localhost', '127.0.0.1'));
  return !in_array(strtolower($host), $proxy_exceptions, TRUE);
}

To avoid confusion, I think the cURL HTTP Request module should use the same format as core (but if we do implement a wildcard system, it should be backward-compatible with variables defined using the current approach, and we should contribute that back to core).