Remove getHandler

It is not supported, and its current form was not documented.
If you need to proxy a request without listening on a port, just
dispatch a 'request' event on the return value of createServer().
This commit is contained in:
Rob Wu
2016-02-26 16:21:59 +01:00
parent 1308e34247
commit fc9cf157d2
2 changed files with 15 additions and 18 deletions

View File

@@ -207,7 +207,7 @@ function parseURL(req_url) {
}
// Request handler factory
var getHandler = exports.getHandler = function(options, proxy) {
function getHandler(options, proxy) {
var corsAnywhere = {
getProxyForUrl: getProxyForUrl, // Function that specifies the proxy to use
maxRedirects: 5, // Maximum number of redirects to be followed.
@@ -217,13 +217,13 @@ var getHandler = exports.getHandler = function(options, proxy) {
removeHeaders: [], // Strip these request headers.
setHeaders: {}, // Set these request headers.
};
if (options) {
Object.keys(corsAnywhere).forEach(function(option) {
if (Object.prototype.hasOwnProperty.call(options, option)) {
corsAnywhere[option] = options[option];
}
});
}
Object.keys(corsAnywhere).forEach(function(option) {
if (Object.prototype.hasOwnProperty.call(options, option)) {
corsAnywhere[option] = options[option];
}
});
// Convert corsAnywhere.requireHeader to an array of lowercase header names, or null.
if (corsAnywhere.requireHeader) {
if (typeof corsAnywhere.requireHeader === 'string') {
@@ -321,7 +321,7 @@ var getHandler = exports.getHandler = function(options, proxy) {
proxyRequest(req, res, proxy);
};
};
}
// Create server with default and given values
// Creator still needs to call .listen()