http-proxy-middleware
Advanced tools
Comparing version 0.8.1 to 0.8.2
@@ -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'); | ||
}); | ||
}); |
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
85653
25
1500