Permalink
Browse files

support web proxy via http_proxy env var

  • Loading branch information...
1 parent 05af361 commit 35c2b63d2c38eb91dcc232bab06fc3c07ca1dc47 @stmuk stmuk committed May 22, 2014
Showing with 14 additions and 2 deletions.
  1. +14 −2 lib/Panda/Ecosystem.pm
View
@@ -65,10 +65,22 @@ class Panda::Ecosystem {
method update {
try unlink $!projectsfile;
- my $s = IO::Socket::INET.new(:host<feather.perl6.nl>, :port(3000));
- $s.send("GET /projects.json HTTP/1.0\n\n");
+ my $s;
+ 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) = '';
$buf ~= $g while $g = $s.get;
+
+ if %*ENV<http_proxy> {
+ $buf.=subst(:g,/'git://'/,'http://');
+ }
given open($!projectsfile, :w) {
.say: $buf.split(/\r?\n\r?\n/, 2)[1];

0 comments on commit 35c2b63

Please sign in to comment.