Skip to content
This repository has been archived by the owner on Jun 19, 2020. It is now read-only.

Commit

Permalink
Fixes http headers in casper.open
Browse files Browse the repository at this point in the history
Original http headers should be set only after the
query append, not immediately after calling webpage.openUrl.
The request initialization may take time, and so customHeaders
are not send because they are erased by the original value
before the request initialization. (at least in Gecko)
  • Loading branch information
laurentj committed Jul 2, 2013
1 parent b49e616 commit 00747d8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions modules/casper.js
Expand Up @@ -1384,12 +1384,15 @@ Casper.prototype.open = function open(location, settings) {
this.page.customHeaders = utils.mergeObjects(utils.clone(baseCustomHeaders), customHeaders);
// perfom request
this.browserInitializing = true;
var self = this;
this.page.openUrl(this.requestUrl, {
operation: settings.method,
data: settings.data
}, this.page.settings);
// revert base custom headers
this.page.customHeaders = baseCustomHeaders;
}, this.page.settings, function(){
// revert base custom headers
self.page.customHeaders = baseCustomHeaders;
});

return this;
};

Expand Down

0 comments on commit 00747d8

Please sign in to comment.