Socket
Socket
Sign inDemoInstall

http-proxy-middleware

Package Overview
Dependencies
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-proxy-middleware - npm Package Compare versions

Comparing version 0.8.1 to 0.8.2

test/proxy-agent.spec.js0

4

lib/handlers.js

@@ -7,4 +7,6 @@ module.exports = {

var host = (req.headers && req.headers.host);
res.writeHead(500);
if (!res.headersSent) {
res.writeHead(500);
}
res.end('Error occured while trying to proxy to: '+ host + req.url);
};
{
"name": "http-proxy-middleware",
"version": "0.8.1",
"version": "0.8.2",
"description": "The one-liner node.js proxy middleware for connect, express and browser-sync",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -34,9 +34,14 @@ var expect = require('chai').expect;

return v;
}
},
headersSent : false
};
// simulate proxy error
handlers.proxyError(mockError, mockReq, mockRes, proxyOptions);
afterEach(function(){
httpErrorCode = undefined;
errorMessage = undefined;
});
it('should set the http status code to: 500', function () {
handlers.proxyError(mockError, mockReq, mockRes, proxyOptions);
expect(httpErrorCode).to.equal(500);

@@ -46,5 +51,18 @@ });

it('should end the response and return error message', function () {
handlers.proxyError(mockError, mockReq, mockRes, proxyOptions);
expect(errorMessage).to.equal('Error occured while trying to proxy to: localhost:3000/api');
});
it('should not set the http status code to: 500 if headers have already been sent', function () {
mockRes.headersSent = true;
handlers.proxyError(mockError, mockReq, mockRes, proxyOptions);
expect(httpErrorCode).to.equal(undefined);
});
it('should end the response and return error message', function () {
mockRes.headersSent = true;
handlers.proxyError(mockError, mockReq, mockRes, proxyOptions);
expect(errorMessage).to.equal('Error occured while trying to proxy to: localhost:3000/api');
});
});
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