Skip to content

Commit 5007bd3

Browse files
committed
Don't send requests with Connection:keep-alive if we have no agent.
Avoids unhandleable ECONNRESETs.
1 parent 94ec6fa commit 5007bd3

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/caronte/common.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,15 @@ common.setupOutgoing = function(outgoing, options, req, forward) {
3737
extend(outgoing.headers, options.headers);
3838
}
3939

40-
outgoing.agent = options.agent || false;
40+
if (options.agent) {
41+
outgoing.agent = options.agent;
42+
} else {
43+
outgoing.agent = false;
44+
// If we have no agent for sharing connections, we should not keep the
45+
// connection alive.
46+
if (outgoing.headers)
47+
outgoing.headers.connection = 'close';
48+
}
4149
outgoing.path = req.url;
4250

4351
return outgoing;

0 commit comments

Comments
 (0)