Skip to content

Commit

Permalink
Add support for proxies (patch by Christopher Jones)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjori committed May 31, 2008
1 parent aa4e898 commit 72b3187
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pear/fetch.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,18 @@ function stream_notification_callback($notification_code, $severity, $message, $

isset($argv[1], $argv[2]) or usage($argv);

$ctx = stream_context_create(null, array("notification" => "stream_notification_callback"));
if (!isset($_ENV['http_proxy'])) {
$copt = null;
} else {
$copt = array(
'http' => array(
'proxy' => preg_replace('/^http/i', 'tcp', $_ENV['http_proxy']),
'request_fulluri' => true,
),
);
}

$ctx = stream_context_create($copt, array("notification" => "stream_notification_callback"));

$fp = fopen($argv[1], "r", false, $ctx);
if (is_resource($fp) && file_put_contents($argv[2], $fp)) {
Expand Down

0 comments on commit 72b3187

Please sign in to comment.