From e08d4edad339d0f7f55900b3e6e6a0e770960215 Mon Sep 17 00:00:00 2001 From: yawnt Date: Sun, 15 Sep 2013 18:02:00 +0200 Subject: [PATCH] [fix] write status --- lib/caronte/index.js | 4 ++-- lib/caronte/passes/{web.js => web-incoming.js} | 2 +- lib/caronte/passes/web-outgoing.js | 6 ++++++ lib/caronte/passes/{ws.js => ws-incoming.js} | 0 4 files changed, 9 insertions(+), 3 deletions(-) rename lib/caronte/passes/{web.js => web-incoming.js} (97%) rename lib/caronte/passes/{ws.js => ws-incoming.js} (100%) diff --git a/lib/caronte/index.js b/lib/caronte/index.js index 4f4139d..30db143 100644 --- a/lib/caronte/index.js +++ b/lib/caronte/index.js @@ -1,6 +1,6 @@ var caronte = exports, - web = require('./passes/web'); - ws = require('./passes/ws'); + web = require('./passes/web-incoming'); + ws = require('./passes/ws-incoming'); caronte.createWebProxy = createRightProxy('web'); caronte.createWsProxy = createRightProxy('ws'); diff --git a/lib/caronte/passes/web.js b/lib/caronte/passes/web-incoming.js similarity index 97% rename from lib/caronte/passes/web.js rename to lib/caronte/passes/web-incoming.js index c7a925d..6906ae8 100644 --- a/lib/caronte/passes/web.js +++ b/lib/caronte/passes/web-incoming.js @@ -91,7 +91,7 @@ function XHeaders(req, res, options) { function stream(req, res, options) { if(options.forward) { - var forwardReq = (options.target.protocol === 'https:' ? https : http).request( + var forwardReq = (options.forward.protocol === 'https:' ? https : http).request( common.setupOutgoing(options.ssl || {}, options, req, 'forward') ); req.pipe(forwardReq); diff --git a/lib/caronte/passes/web-outgoing.js b/lib/caronte/passes/web-outgoing.js index b0f86ce..4e98151 100644 --- a/lib/caronte/passes/web-outgoing.js +++ b/lib/caronte/passes/web-outgoing.js @@ -9,11 +9,17 @@ var passes = exports; */ [ // <-- + + function writeStatusCode(res, proxyRes) { + res.writeHead(proxyRes.statusCode); + }, + function writeHeaders(res, proxyRes) { Object.keys(proxyRes.headers).forEach(function(key) { res.setHeader(key, proxyRes.headers[key]); }); } + ] // <-- .forEach(function(func) { passes[func.name] = func; diff --git a/lib/caronte/passes/ws.js b/lib/caronte/passes/ws-incoming.js similarity index 100% rename from lib/caronte/passes/ws.js rename to lib/caronte/passes/ws-incoming.js