Skip to content

Commit

Permalink
Drain out empty response to close the connection
Browse files Browse the repository at this point in the history
fixes #640
  • Loading branch information
krishnasrinivas committed Nov 2, 2017
1 parent 0cd4ecc commit 29fe344
Showing 1 changed file with 40 additions and 8 deletions.
48 changes: 40 additions & 8 deletions src/main/minio.js
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,10 @@ export class Client {
var headers = {}
// virtual-host-style request but signed with region 'us-east-1'
// makeBucket request has to be always signed bye 'us-east-1'
this.makeRequest({method, bucketName, headers}, payload, 200, 'us-east-1', (e) => {
this.makeRequest({method, bucketName, headers}, payload, 200, 'us-east-1', (e, response) => {
if (!e) {
response.on('data', ()=>{})
}
if (e && e.name === 'AuthorizationHeaderMalformed') {
// if the bucket already exists in non-standard location we try again
// by signing the request with the correct region and S3 returns:
Expand Down Expand Up @@ -637,7 +640,12 @@ export class Client {
throw new TypeError('callback should be of type "function"')
}
var method = 'HEAD'
this.makeRequest({method, bucketName}, '', 200, '', cb)
this.makeRequest({method, bucketName}, '', 200, '', (e, response) => {
if (!e) {
response.on('data', ()=>{})
}
cb(e)
})
}

// Remove a bucket.
Expand All @@ -653,9 +661,12 @@ export class Client {
throw new TypeError('callback should be of type "function"')
}
var method = 'DELETE'
this.makeRequest({method, bucketName}, '', 204, '', (e) => {
this.makeRequest({method, bucketName}, '', 204, '', (e, response) => {
// If the bucket was successfully removed, remove the region map entry.
if (!e) delete(this.regionMap[bucketName])
if (!e) {
delete(this.regionMap[bucketName])
response.on('data', ()=>{})
}
cb(e)
})
}
Expand Down Expand Up @@ -688,7 +699,12 @@ export class Client {
cb => {
var method = 'DELETE'
var query = `uploadId=${removeUploadId}`
this.makeRequest({method, bucketName, objectName, query}, '', 204, '', e => cb(e))
this.makeRequest({method, bucketName, objectName, query}, '', 204, '', (e, response) => {
if (!e) {
response.on('data', ()=>{})
}
cb(e)
})
},
cb
)
Expand Down Expand Up @@ -1364,6 +1380,7 @@ export class Client {
var method = 'HEAD'
this.makeRequest({method, bucketName, objectName}, '', 200, '', (e, response) => {
if (e) return cb(e)
response.on('data', () => {})
var result = {
size: +response.headers['content-length'],
contentType: response.headers['content-type'],
Expand Down Expand Up @@ -1395,7 +1412,12 @@ export class Client {
throw new TypeError('callback should be of type "function"')
}
var method = 'DELETE'
this.makeRequest({method, bucketName, objectName}, '', 204, '', cb)
this.makeRequest({method, bucketName, objectName}, '', 204, '', (e, response) => {
if (!e) {
response.on('data', ()=>{})
}
cb(e)
})
}

// Get the policy on a bucket or an object prefix.
Expand Down Expand Up @@ -1470,7 +1492,12 @@ export class Client {
policyPayload = JSON.stringify(policyPayload)
}

this.makeRequest({method, bucketName, query}, policyPayload, 204, '', cb)
this.makeRequest({method, bucketName, query}, policyPayload, 204, '', (e, response) => {
if (!e) {
response.on('data', ()=>{})
}
cb(e)
})
}

// Generate a generic presigned URL which can be
Expand Down Expand Up @@ -1956,7 +1983,12 @@ export class Client {
var query = 'notification'
var builder = new xml2js.Builder({rootName:'NotificationConfiguration', renderOpts:{'pretty':false}, headless:true})
var payload = builder.buildObject(config)
this.makeRequest({method, bucketName, query}, payload, 200, '', cb)
this.makeRequest({method, bucketName, query}, payload, 200, '', (e, response) => {
if (!e) {
response.on('data', ()=>{})
}
cb(e)
})
}

removeAllBucketNotification(bucketName, cb) {
Expand Down

0 comments on commit 29fe344

Please sign in to comment.