Permalink
Browse files

Merge pull request #1109 from rafis/master

Fix bug in filtering handlers in pipeline.js
2 parents 942bd9c + 40b2bc0 commit aa987234b2a43595a34c4bf01017087110e6b9aa @assaf committed on GitHub Mar 25, 2017
Showing with 12 additions and 2 deletions.
  1. +12 −2 src/pipeline.js
View
@@ -52,7 +52,7 @@ class Pipeline extends Array {
_getOriginalResponse(request) {
const browser = this._browser;
- const requestHandlers = this.filter(fn => fn.length === 2).concat(Pipeline.makeHTTPRequest);
+ const requestHandlers = this.getRequestHandlers().concat(Pipeline.makeHTTPRequest);
return Bluebird.reduce(requestHandlers, function(lastResponse, requestHandler) {
return lastResponse || requestHandler(browser, request);
@@ -65,7 +65,7 @@ class Pipeline extends Array {
_prepareResponse(request, originalResponse) {
const browser = this._browser;
- const responseHandlers = this.filter(fn => fn.length === 3);
+ const responseHandlers = this.getResponseHandlers();
return Bluebird.reduce(responseHandlers, function(lastResponse, responseHandler) {
return responseHandler(browser, request, lastResponse);
@@ -113,6 +113,16 @@ class Pipeline extends Array {
}
}
+ // Get array of request handlers
+ getRequestHandlers() {
+ return [].concat(this).filter(fn => fn.length === 2);
+ }
+
+ // Get array of request handlers
+ getResponseHandlers() {
+ return [].concat(this).filter(fn => fn.length === 3);
+ }
+
// -- Prepare request --

0 comments on commit aa98723

Please sign in to comment.