Skip to content

Commit

Permalink
Drain data from response to close the socket
Browse files Browse the repository at this point in the history
fixes minio#654
  • Loading branch information
krishnasrinivas committed Dec 20, 2017
1 parent b2ae576 commit 7dc5cb2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main/minio.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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'],
Expand Down

0 comments on commit 7dc5cb2

Please sign in to comment.