Skip to content

Commit

Permalink
Merge pull request nsimmons#30 from ragalie/dont-set-connection-close
Browse files Browse the repository at this point in the history
Don't set Connection: close by default
  • Loading branch information
Nicholas Simmons authored Jan 21, 2021
2 parents 4544e12 + 349d738 commit cb83794
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
5 changes: 1 addition & 4 deletions lib/requestOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ function reqHeaders(ctx, options) {
if (!options.preserveHostHdr) {
skipHdrs.push('host');
}
var hds = extend(headers, ctx.headers, skipHdrs);
hds.connection = 'close';

return hds;
return extend(headers, ctx.headers, skipHdrs);
}

function createRequestOptions(ctx, options) {
Expand Down
21 changes: 21 additions & 0 deletions test/headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,27 @@ describe('proxies headers', function() {
}));
});

it('does not include connection header by default', function(done) {
var app = new Koa();
app.use(proxy('httpbin.org', {
proxyReqOptDecorator: function(reqOpts, ctx) {
try {
assert(!reqOpts.headers.connection);
} catch (err) {
done(err);
}
return ctx;
}
}));

agent(app.callback())
.get('/user-agent')
.end(function(err) {
if (err) { return done(err); }
done();
});
});

it('passed as options', function(done) {
agent(http.callback())
.get('/headers')
Expand Down

0 comments on commit cb83794

Please sign in to comment.