proxy-chain
Advanced tools
Comparing version 0.4.1 to 0.4.2
@@ -263,5 +263,11 @@ 'use strict'; | ||
this.close(); | ||
} else if (err.statusCode) { | ||
return; | ||
} | ||
this.srcGotResponse = true; | ||
this.srcResponse.setHeader('Content-Type', 'text/plain; charset=utf-8'); | ||
if (err.statusCode) { | ||
// Error is RequestError with HTTP status code | ||
this.log(err + ', responding with custom status code ' + err.statusCode + ' to client'); | ||
this.log(err + ' Responding with custom status code ' + err.statusCode + ' to client'); | ||
this.srcResponse.writeHead(err.statusCode); | ||
@@ -268,0 +274,0 @@ this.srcResponse.end('' + err.message); |
@@ -66,2 +66,3 @@ 'use strict'; | ||
// Forward custom response to source | ||
_this2.srcGotResponse = true; | ||
_this2.srcResponse.statusCode = statusCode; | ||
@@ -68,0 +69,0 @@ |
@@ -467,6 +467,7 @@ 'use strict'; | ||
if (!headers['Content-Type']) { | ||
headers['Content-Type'] = 'text/html; charset=utf-8'; | ||
// TODO: We should use fully case-insensitive lookup here! | ||
if (!headers['Content-Type'] && !headers['content-type']) { | ||
headers['Content-Type'] = 'text/plain; charset=utf-8'; | ||
} | ||
if (statusCode === 407 && !headers['Proxy-Authenticate']) { | ||
if (statusCode === 407 && !headers['Proxy-Authenticate'] && !headers['proxy-authenticate']) { | ||
headers['Proxy-Authenticate'] = 'Basic realm="' + this.authRealm + '"'; | ||
@@ -481,3 +482,3 @@ } | ||
} | ||
if (!headers['Content-Length']) { | ||
if (!headers['Content-Length'] && !headers['content-length']) { | ||
headers['Content-Length'] = Buffer.byteLength(message); | ||
@@ -484,0 +485,0 @@ } |
@@ -0,1 +1,8 @@ | ||
0.4.2 / 2020-02-28 | ||
=================== | ||
- Bugfix: Prevented attempted double-sending of certain HTTP responses to client, | ||
which might have caused some esoteric errors | ||
- Error responses now by default have `Content-Type: text/plain; charset=utf-8` instead | ||
of `text/html; charset=utf-8` or missing one. | ||
0.4.1 / 2020-02-22 | ||
@@ -2,0 +9,0 @@ =================== |
{ | ||
"name": "proxy-chain", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"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", |
@@ -97,3 +97,4 @@ # Programmable HTTP proxy server for Node.js | ||
you can throw the `RequestError` from inside of the `prepareRequestFunction` function. | ||
The class constructor has the following parameters: `RequestError(body, statusCode, headers)` | ||
The class constructor has the following parameters: `RequestError(body, statusCode, headers)`. | ||
By default, the response will have `Content-Type: text/plain; charset=utf-8`. | ||
@@ -100,0 +101,0 @@ ```javascript |
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
127199
1886
316