express-http-proxy
Advanced tools
Comparing version 0.2.2 to 0.3.0
15
index.js
@@ -5,6 +5,6 @@ var assert = require('assert'); | ||
var http = require('http'); | ||
var https = require('https'); | ||
var is = require('type-is'); | ||
var getRawBody = require('raw-body'); | ||
require('buffer'); | ||
@@ -20,2 +20,4 @@ | ||
var ishttps = /^https/.test(host); | ||
if (typeof host == 'string') { | ||
@@ -26,6 +28,6 @@ var mc = host.match(/^(https?:\/\/)/); | ||
} | ||
var h = host.split(':'); | ||
host = h[0]; | ||
port = h[1] || 80; | ||
port = h[1] || (ishttps ? 443 : 80); | ||
} | ||
@@ -83,3 +85,3 @@ | ||
var chunks = []; | ||
var realRequest = http.request(reqOpt, function(rsp) { | ||
var realRequest = (ishttps ? https : http).request(reqOpt, function(rsp) { | ||
var rspData = null; | ||
@@ -119,4 +121,5 @@ rsp.on('data', function(chunk) { | ||
}); | ||
} else | ||
} else { | ||
res.send(rspData); | ||
} | ||
}); | ||
@@ -156,3 +159,3 @@ | ||
for (var prop in source) { | ||
if (skips.indexOf(prop) == -1) | ||
if (!skips || skips.indexOf(prop) == -1) | ||
obj[prop] = source[prop]; | ||
@@ -159,0 +162,0 @@ } |
{ | ||
"name": "express-http-proxy", | ||
"version": "0.2.2", | ||
"version": "0.3.0", | ||
"description": "http proxy middleware for express", | ||
@@ -38,18 +38,17 @@ "main": "index.js", | ||
}, | ||
"contributors": [ | ||
{ | ||
"name": "Wei Gao", | ||
"email": "jky239@gmail.com" | ||
}, | ||
{ | ||
"contributors": [{ | ||
"name": "Liam Bennett" | ||
}, | ||
{ | ||
"name": "Saulius Menkevičius" | ||
}, | ||
{ | ||
}, { | ||
"name": "eldereal", | ||
"url": "https://github.com/eldereal" | ||
}, { | ||
"name": "Saulius Menkevičius", | ||
"url": "https://github.com/razzmatazz" | ||
}, { | ||
"name": "Jérémy Lal", | ||
"email": "kapouer@melix.org" | ||
} | ||
] | ||
}, { | ||
"name": "Wei Gao", | ||
"email": "jky239@gmail.com" | ||
}] | ||
} |
@@ -15,2 +15,16 @@ var assert = require('assert'); | ||
describe('test https', function() { | ||
it('https', function(done) { | ||
var https = express(); | ||
https.use(proxy('https://httpbin.org')); | ||
request(https) | ||
.get('/user-agent') | ||
.end(function(err, res) { | ||
if (err) return done(err); | ||
assert(res.body); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
describe('test intercept & decorateRequest', function() { | ||
@@ -17,0 +31,0 @@ it('decorateRequest', function(done) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12342
10
260
2