summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/proxy/proxy.js15
1 files changed, 11 insertions, 4 deletions
diff --git a/modules/proxy/proxy.js b/modules/proxy/proxy.js
index 66c50df..e18ab6a 100644
--- a/modules/proxy/proxy.js
+++ b/modules/proxy/proxy.js
@@ -15,7 +15,7 @@ function fetch(method,url,cb){
var body="";
res.on("data",function(data){body+=data;});
res.on("end",function(){
- cb(res.statusCode,body);
+ cb({status: res.statusCode, headers: res.headers},body);
});
}).on("error",function(){
cb(null,null);
@@ -37,9 +37,16 @@ module.exports=function(app,io,moddir){
var id=req.params.id;
var path="/"+req.path.split("/").slice(3).join("/");
if(iddict[id]){
- fetch(req.method,iddict[id]+path,function(status,body){
- if(status==null)res.status(500).send("An error occurred...\n");
- else res.status(status).send(body);
+ fetch(req.method,iddict[id]+path,function(obj,body){
+ if(obj.status==null){
+ res.status(500).send("An error occurred...\n");
+ return;
+ }
+ res.status(obj.status);
+ if(obj.headers["content-type"]){
+ res.set("Content-Type",obj.headers["content-type"]);
+ }
+ res.send(body);
});
} else {
res.status(404).send(