Commit 70f42746 authored by Fabian Jakobs's avatar Fabian Jakobs
Browse files

actually propagate the error to be consistent with errors propagates by http.request

1 merge request!965Catch invalid headers
Pipeline #1333 failed with stages
Showing with 11 additions and 8 deletions
+11 -8
......@@ -145,9 +145,16 @@ web_o = Object.keys(web_o).map(function(pass) {
(options.buffer || req).pipe(proxyReq);
proxyReq.on('response', function(proxyRes) {
if(server) { server.emit('proxyRes', proxyRes, req, res); }
for(var i=0; i < web_o.length; i++) {
if(web_o[i](req, res, proxyRes, options)) { break; }
var stop = false;
if (server) { server.emit('proxyRes', proxyRes, req, res); }
for (var i=0; i < web_o.length; i++) {
try {
stop = web_o[i](req, res, proxyRes, options);
} catch(e) {
return proxyError(e);
}
if (stop) { break; }
}
// Allow us to listen when the proxy has completed
......
......@@ -83,11 +83,7 @@ var redirectRegex = /^30(1|2|7|8)$/;
function writeHeaders(req, res, proxyRes) {
Object.keys(proxyRes.headers).forEach(function(key) {
if (proxyRes.headers[key] != undefined) {
try {
res.setHeader(key, proxyRes.headers[key]);
} catch (e) {
// ignore invalid headers
}
res.setHeader(key, proxyRes.headers[key]);
}
});
},
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment