From 7dc5cb2c0bc5620f51e8193efa30d549b2189feb Mon Sep 17 00:00:00 2001 From: Krishna Srinivas Date: Wed, 13 Dec 2017 11:02:31 -0800 Subject: [PATCH] Drain data from response to close the socket fixes #654 --- src/main/minio.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/minio.js b/src/main/minio.js index 38f8af14..e68a7e9b 100644 --- a/src/main/minio.js +++ b/src/main/minio.js @@ -410,7 +410,9 @@ export class Client { } this.logHTTP(reqOptions, response) if (returnResponse) return cb(null, response) - response.socket.end() + // We drain the socket so that the connection gets closed. Note that this + // is not expensive as the socket will not have any data. + response.on('data', ()=>{}) cb(null) }) let pipe = pipesetup(stream, req) @@ -1372,7 +1374,11 @@ export class Client { var method = 'HEAD' this.makeRequest({method, bucketName, objectName}, '', 200, '', true, (e, response) => { if (e) return cb(e) - else response.socket.end() + + // We drain the socket so that the connection gets closed. Note that this + // is not expensive as the socket will not have any data. + response.on('data', ()=>{}) + var result = { size: +response.headers['content-length'], contentType: response.headers['content-type'],