Skip to content

Commit

Permalink
Merge pull request #83 from stmuk/master
Browse files Browse the repository at this point in the history
support web proxy via http_proxy env var
  • Loading branch information
Tadeusz Sośnierz committed May 23, 2014
2 parents 05af361 + 35c2b63 commit 30357d3
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/Panda/Ecosystem.pm
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -65,10 +65,22 @@ class Panda::Ecosystem {


method update { method update {
try unlink $!projectsfile; try unlink $!projectsfile;
my $s = IO::Socket::INET.new(:host<feather.perl6.nl>, :port(3000)); my $s;
$s.send("GET /projects.json HTTP/1.0\n\n"); if %*ENV<http_proxy> {
my ($host, $port) = %*ENV<http_proxy>.split('/').[2].split(':');
$s = IO::Socket::INET.new(host=>$host, port=>$port.Int);
$s.send("GET http://feather.perl6.nl:3000/projects.json HTTP/1.1\nHost: feather.perl6.nl\nAccept: */*\nConnection: Close\n\n");
}
else {
$s = IO::Socket::INET.new(:host<feather.perl6.nl>, :port(3000));
$s.send("GET /projects.json HTTP/1.0\n\n");
}
my ($buf, $g) = ''; my ($buf, $g) = '';
$buf ~= $g while $g = $s.get; $buf ~= $g while $g = $s.get;

if %*ENV<http_proxy> {
$buf.=subst(:g,/'git://'/,'http://');
}


given open($!projectsfile, :w) { given open($!projectsfile, :w) {
.say: $buf.split(/\r?\n\r?\n/, 2)[1]; .say: $buf.split(/\r?\n\r?\n/, 2)[1];
Expand Down

0 comments on commit 30357d3

Please sign in to comment.