Skip to content

Commit

Permalink
Bug fixes and tidy up of clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
James Haley committed Feb 19, 2015
1 parent b15697d commit 87b9f76
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ These might get done if we end up needing them/have time:

## Release History

* 0.0.6 Bug fixes introduced in the last update and clean up was happening too soon. Moved it.
* 0.0.5 Added the ability to passthrough specific information from the `.add()` options to the response object
* 0.0.4 Authorization can now be set on each request (currently Bearer [...] only)
* 0.0.3 More bug fixes: New contentId for every request
Expand Down
17 changes: 10 additions & 7 deletions lib/batchelor.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ var request = require('request'),

// Get the response id if exists
var returnedContentId = part.header['content-id'],
currentRequestCallback,
currentRequestExtendData;
currentRequestCallback = null,
currentRequestExtendData = null;

if (!!returnedContentId) {

Expand All @@ -234,7 +234,9 @@ var request = require('request'),

// If this individual request has a callback, run it
if (!!currentRequestCallback) {

currentRequestCallback(part.data, currentRequestExtendData || null);

} else {
// Anything that doesn't have a specific callback get's pushed into main body
responseBody.parts.push(part.data);
Expand All @@ -247,15 +249,16 @@ var request = require('request'),
// Extend data sent through as is for parse in callback
callback(responseBody, _requestExtensionData);

// Clean up
_requests = [];
_requestExtensionData = [];
_requestSpecificCallbacks = [];
_multiparts = [];

});

// Pipe our response to Dicer
responseObj.pipe(d);
}).on('end', function () {

// Clean up
_requests = _requestExtensionData = _requestSpecificCallbacks = _multiparts = [];

});
};

Expand Down

0 comments on commit 87b9f76

Please sign in to comment.