diff options
Diffstat (limited to 'build/server.js')
| -rw-r--r-- | build/server.js | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/build/server.js b/build/server.js index 737e47b..09fa596 100644 --- a/build/server.js +++ b/build/server.js @@ -1,4 +1,4 @@ -// Generated by Haxe 4.1.0 +// Generated by Haxe 4.1.1 (function ($global) { "use strict"; var $estr = function() { return js_Boot.__string_rec(this,''); },$hxEnums = $hxEnums || {},$_; function $extend(from, fields) { @@ -3268,26 +3268,49 @@ server_HttpServer.localizeHtml = function(data,lang) { return data; }; server_HttpServer.proxyUrl = function(req,res) { - var url = StringTools.replace(req.url,"/proxy?url=",""); + var proxy = server_HttpServer.proxyRequest(StringTools.replace(req.url,"/proxy?url=",""),req,res,function(proxyReq) { + var url = proxyReq.headers["location"]; + if(url == null) { + return false; + } + var proxy2 = server_HttpServer.proxyRequest(url,req,res,function(proxyReq) { + return false; + }); + if(proxy2 == null) { + res.end("Proxy error for redirected " + url); + return true; + } + req.pipe(proxy2,{ end : true}); + return true; + }); + if(proxy == null) { + return false; + } + req.pipe(proxy,{ end : true}); + return true; +}; +server_HttpServer.proxyRequest = function(url,req,res,fn) { var url1; try { url1 = new js_node_url_URL(global.decodeURI(url)); } catch( _g ) { - return false; + return null; } if(url1.host == req.headers["host"]) { - return false; + return null; } - var proxy = (url1.protocol == "https:" ? js_node_Https.request : js_node_Http.request)({ host : url1.host, port : Std.parseInt(url1.port), path : url1.pathname + url1.search, method : req.method},function(proxyRes) { - proxyRes.headers["Content-Type"] = "application/octet-stream"; - res.writeHead(proxyRes.statusCode,proxyRes.headers); - proxyRes.pipe(res,{ end : true}); + var proxy = (url1.protocol == "https:" ? js_node_Https.request : js_node_Http.request)({ host : url1.host, port : Std.parseInt(url1.port), path : url1.pathname + url1.search, method : req.method},function(proxyReq) { + if(fn(proxyReq)) { + return; + } + proxyReq.headers["Content-Type"] = "application/octet-stream"; + res.writeHead(proxyReq.statusCode,proxyReq.headers); + proxyReq.pipe(res,{ end : true}); }); proxy.on("error",function(err) { res.end("Proxy error for " + url1.href); }); - req.pipe(proxy,{ end : true}); - return true; + return proxy; }; server_HttpServer.isChildOf = function(parent,child) { var rel = js_node_Path.relative(parent,child); |
