Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

under

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

under - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

pipe_error.js

43

lib/proxy.js

@@ -12,3 +12,5 @@ /*

var debug = false;
var debug = false,
retry_failed = false;
var defaults = {};

@@ -110,6 +112,9 @@

if (opts.retry_failed)
retry_failed = opts.retry_failed;
return exports.send;
}
exports.send = function(req, res){
exports.send = function(req, res) {

@@ -130,3 +135,3 @@ log('Proxying request to ' + req.url);

var header_func = opts.lowercase ? function(h){ return h } : upperize;
var header_func = opts.lowercase ? function(h) { return h } : upperize;
// req.connection.setTimeout(timeout); // we'll set or own timer

@@ -157,3 +162,3 @@

var done = function(err){
var done = function(err) {
if (returned) return;

@@ -164,3 +169,3 @@ cb && cb(err, res);

var proxyError = function(err){
var proxyError = function(err) {
error = true;

@@ -171,4 +176,12 @@ if (timer) clearTimeout(timer);

if (!res.headersSent) {
var code = req.aborted ? 499 : (errors[err.code] || 500);
res.writeHead(code, {'Content-Type': 'text/plain', 'Connection': 'close'});
if (retry_failed === true && !opts.retried) {
// retry is enabled, so wait one second and resend the request
return setTimeout(function() {
opts.retried = true;
exports.send(req, res, opts, cb);
}, 1000);
} else {
var code = req.aborted ? 499 : (errors[err.code] || 500);
res.writeHead(code, {'Content-Type': 'text/plain', 'Connection': 'close'});
}
}

@@ -189,3 +202,3 @@

var proxyRequest = http.request(request_opts, function(response){
var proxyRequest = http.request(request_opts, function(response) {

@@ -230,3 +243,3 @@ if (timer) clearTimeout(timer);

response.once('end', function(){
response.once('end', function() {
// log('Proxy response ended.')

@@ -252,3 +265,3 @@ if (error) return;

req.once('close', function() {
// log('Request closed.')
log('Request closed.')
if (!error) proxyRequest.abort();

@@ -278,4 +291,8 @@ });

// if we proxied a HEAD request and we received a body, we would get this error
if (req.method == 'HEAD' && err.code == 'HPE_INVALID_CONSTANT') {
log('HEAD response contained a body!')
if (err.code == 'HPE_INVALID_CONSTANT') {
if (req.method == 'HEAD') {
log('HEAD response contained a body!')
} else {
log('Invalid Content-Length!');
}
return res.end();

@@ -290,3 +307,3 @@ }

} else {
req.once('end', function(){
req.once('end', function() {
if (!error) proxyRequest.end();

@@ -293,0 +310,0 @@ });

{
"name": "under",
"version": "0.1.4",
"version": "0.1.5",
"description": "Fast reverse HTTP proxy with load balancing and queue support.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "mocha test"
},

@@ -9,0 +9,0 @@ "repository": "",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc