@@ -56,7 +56,19 @@ class Main {
56
56
static function authenticate (params , infos , callback )
57
57
{
58
58
trace (' INFO: authenticating on the upstream repo $infos ' );
59
- var req = Https .request (' https:// ${params .repo }/info/refs?service= ${params .service }' , callback );
59
+ var req : ClientRequest ;
60
+ if (proxyAgent == null ) {
61
+ req = Https .request (' https:// ${params .repo }/info/refs?service= ${params .service }' , callback );
62
+ }
63
+ else {
64
+ var opts : Https . HttpsRequestOptions = {};
65
+ opts .protocol = " https:" ;
66
+ opts .host = params .repo ;
67
+ opts .path = ' /info/refs?service= ${params .service }' ;
68
+ opts .agent = proxyAgent ;
69
+ req = Https .request (opts , callback );
70
+ }
71
+
60
72
req .setHeader (" User-Agent" , " git/" );
61
73
if (params .auth != null )
62
74
req .setHeader (" Authorization" , params .auth .authorization );
@@ -194,6 +206,7 @@ class Main {
194
206
static var updatePromises = new Map <String , Promise <Dynamic >>();
195
207
static var cacheDir = " /tmp/var/cache/git/" ;
196
208
static var listenPort = 8080 ;
209
+ static var proxyAgent = null ;
197
210
static var usage = "
198
211
A caching Git HTTP server.
199
212
@@ -219,6 +232,14 @@ Options:
219
232
220
233
trace (' INFO: cache directory: $cacheDir ' );
221
234
trace (' INFO: listening to port: $listenPort ' );
235
+
236
+ var env = Sys .environment ();
237
+ var proxyUrl = env [" http_proxy" ];
238
+ if (proxyUrl == null )
239
+ proxyUrl = env [" HTTP_PROXY" ];
240
+ if (proxyUrl != null )
241
+ proxyAgent = new HttpsProxyAgent (proxyUrl );
242
+
222
243
var server = Http .createServer (handleRequest );
223
244
server .setTimeout (120 * 60 * 1000 ); // 120 * 60 seconds * 1000 msecs
224
245
server .listen (listenPort );
0 commit comments