Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: http-party/node-http-proxy
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.1.1
Choose a base ref
...
head repository: http-party/node-http-proxy
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.1.2
Choose a head ref
  • 3 commits
  • 3 files changed
  • 1 contributor

Commits on Apr 14, 2014

  1. [fix] handle error on incoming request as well and properly abort pro…

    …xy if client request is aborted
    jcrugzz committed Apr 14, 2014
    Copy the full SHA
    77a1cff View commit details
  2. Copy the full SHA
    61c8734 View commit details
  3. [dist] Version bump. 1.1.2

    jcrugzz committed Apr 14, 2014
    Copy the full SHA
    c54278b View commit details
Showing with 25 additions and 14 deletions.
  1. +12 −6 lib/http-proxy/passes/web-incoming.js
  2. +1 −1 package.json
  3. +12 −7 test/lib-http-proxy-test.js
18 changes: 12 additions & 6 deletions lib/http-proxy/passes/web-incoming.js
Original file line number Diff line number Diff line change
@@ -91,9 +91,7 @@ web_o = Object.keys(web_o).map(function(pass) {

function stream(req, res, options, _, server, clb) {

//
// And we begin!
//
if (!clb) {
server.emit('start', req, res, options.target)
}
@@ -111,14 +109,24 @@ web_o = Object.keys(web_o).map(function(pass) {
common.setupOutgoing(options.ssl || {}, options, req)
);

// Ensure we abort proxy if request is aborted
req.on('aborted', function () {
proxyReq.abort();
});

// Handle errors on incoming request as well as it makes sense to
req.on('error', proxyError);

// Error Handler
proxyReq.on('error', function(err){
proxyReq.on('error', proxyError);

function proxyError (err){
if (clb) {
clb(err, req, res);
} else {
server.emit('error', err, req, res);
}
});
}

(options.buffer || req).pipe(proxyReq);

@@ -128,9 +136,7 @@ web_o = Object.keys(web_o).map(function(pass) {
if(web_o[i](req, res, proxyRes)) { break; }
}

//
// Allow us to listen when the proxy has completed
//
proxyRes.on('end', function () {
if (!clb) {
server.emit('end', req, res, proxyRes);
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name" : "http-proxy",
"version" : "1.1.1",
"version" : "1.1.2",

"repository" : {
"type" : "git",
19 changes: 12 additions & 7 deletions test/lib-http-proxy-test.js
Original file line number Diff line number Diff line change
@@ -78,14 +78,14 @@ describe('lib/http-proxy.js', function() {
});

source.listen(ports.source);

http.request({
hostname: '127.0.0.1',
port: ports.proxy,
method: 'POST',
headers: {
'x-forwarded-for': '127.0.0.1'
}
}
}, function() {}).end();
});
});
@@ -105,7 +105,7 @@ describe('lib/http-proxy.js', function() {
});

source.listen(ports.source);

http.request({
hostname: '127.0.0.1',
port: ports.proxy,
@@ -117,7 +117,7 @@ describe('lib/http-proxy.js', function() {
expect(data.toString()).to.eql('Hello from ' + ports.source);
});

res.on('end', function () {
res.on('end', function () {
source.close();
proxy._server.close();
done();
@@ -141,7 +141,7 @@ describe('lib/http-proxy.js', function() {
})

proxy.listen(ports.proxy);

http.request({
hostname: '127.0.0.1',
port: ports.proxy,
@@ -159,6 +159,11 @@ describe('lib/http-proxy.js', function() {
timeout: 3
}).listen(ports.proxy);

proxy.on('error', function (e) {
expect(e).to.be.an(Error);
expect(e.code).to.be.eql('ECONNRESET');
});

var source = http.createServer(function(req, res) {
setTimeout(function () {
res.end('At this point the socket should be closed');
@@ -207,7 +212,7 @@ describe('lib/http-proxy.js', function() {
// proxy.ee.on('http-proxy:**', function (uno, dos, tres) {
// events.push(this.event);
// })

// http.request({
// hostname: '127.0.0.1',
// port: '8081',
@@ -314,4 +319,4 @@ describe('lib/http-proxy.js', function() {
})
});
})
});
});