proxy-chain
Advanced tools
Comparing version 0.1.32 to 0.1.33
@@ -41,4 +41,4 @@ 'use strict'; | ||
_this.customResponseFunc = options.customResponseFunc; | ||
if (!_this.customResponseFunc) throw new Error('The "customResponseFunc" option is required'); | ||
_this.customResponseFunction = options.customResponseFunction; | ||
if (!_this.customResponseFunction) throw new Error('The "customResponseFunction" option is required'); | ||
return _this; | ||
@@ -57,4 +57,3 @@ } | ||
_bluebird2.default.resolve().then(function () { | ||
var opts = _underscore2.default.pick(_this2, 'srcRequest', 'trgParsed'); | ||
return _this2.customResponseFunc(opts); | ||
return _this2.customResponseFunction(); | ||
}).then(function (customResponse) { | ||
@@ -64,3 +63,3 @@ if (_this2.isClosed) return; | ||
if (!customResponse) { | ||
throw new Error('The user-provided customResponseFunc must return an object.'); | ||
throw new Error('The user-provided "customResponseFunction" must return an object.'); | ||
} | ||
@@ -67,0 +66,0 @@ |
@@ -132,3 +132,3 @@ 'use strict'; | ||
* upstreamProxyUrl: String, | ||
* customResponseFunc: Function | ||
* customResponseFunction: Function | ||
* }``` | ||
@@ -138,3 +138,3 @@ * If `upstreamProxyUrl` is false-ish value, no upstream proxy is used. | ||
* and will not use any upstream proxy. | ||
* If `customResponseFunc` is set, it will be called to generate a custom response to the HTTP request. | ||
* If `customResponseFunction` is set, it will be called to generate a custom response to the HTTP request. | ||
* It should not be used together with `upstreamProxyUrl`. | ||
@@ -202,3 +202,3 @@ * @param [options.authRealm] Realm used in the Proxy-Authenticate header and also in the 'Server' HTTP header. By default it's `ProxyChain`. | ||
var handler = void 0; | ||
if (handlerOpts.customResponseFunc) { | ||
if (handlerOpts.customResponseFunction) { | ||
_this3.log(handlerOpts.id, 'Using HandlerCustomResponse'); | ||
@@ -298,3 +298,3 @@ handler = new _handler_custom_response2.default(handlerOpts); | ||
if (!parsed.protocol) { | ||
throw new RequestError('Hey, good try, but I\'m a HTTP proxy, not an ordinary web server :)', 400); | ||
throw new RequestError('Hey, good try, but I\'m a HTTP proxy, not your ordinary web server :)', 400); | ||
} | ||
@@ -363,10 +363,10 @@ // Only HTTP is supported, other protocols such as HTTP or FTP must use the CONNECT method | ||
if (funcResult && funcResult.customResponseFunc) { | ||
if (funcResult && funcResult.customResponseFunction) { | ||
_this5.log(handlerOpts.id, 'Using custom response function'); | ||
handlerOpts.customResponseFunc = funcResult.customResponseFunc; | ||
handlerOpts.customResponseFunction = funcResult.customResponseFunction; | ||
if (!isHttp) { | ||
throw new Error('The "customResponseFunc" option can only be used for HTTP requests.'); | ||
throw new Error('The "customResponseFunction" option can only be used for HTTP requests.'); | ||
} | ||
if (typeof handlerOpts.customResponseFunc !== 'function') { | ||
throw new Error('The "customResponseFunc" option must be a function.'); | ||
if (typeof handlerOpts.customResponseFunction !== 'function') { | ||
throw new Error('The "customResponseFunction" option must be a function.'); | ||
} | ||
@@ -373,0 +373,0 @@ } |
@@ -0,1 +1,5 @@ | ||
0.1.33 / 2018-06-08 | ||
=================== | ||
- Renamed `customResponseFunc` to `customResponseFunction` and changed parameters for more clarity | ||
0.1.32 / 2018-06-08 | ||
@@ -2,0 +6,0 @@ =================== |
{ | ||
"name": "proxy-chain", | ||
"version": "0.1.32", | ||
"version": "0.1.33", | ||
"description": "Node.js implementation of a proxy server (think Squid) with support for SSL, authentication, upstream proxy chaining, and protocol tunneling.", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
@@ -85,4 +85,5 @@ # Programmable HTTP proxy server for Node.js | ||
To provide a custom response, the result of the `prepareRequestFunction` function must | ||
define the `prepareRequestFunction` property, which contains a function that generates the custom response. | ||
The function must return an object (or a promise resolving to an object) with the following properties: | ||
define the `customResponseFunction` property, which contains a function that generates the custom response. | ||
The function is passed no parameters and it must return an object (or a promise resolving to an object) | ||
with the following properties: | ||
@@ -116,3 +117,3 @@ ```javascript | ||
return { | ||
customResponseFunc: () => { | ||
customResponseFunction: () => { | ||
return { | ||
@@ -119,0 +120,0 @@ statusCode: 200, |
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
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
114705
221
1784