Commit 00747d8d 00747d8df822d259acce7f8e3103c55b11a9b114 by Laurent Jouanneau

Fixes http headers in casper.open

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)
1 parent b49e6165
...@@ -1384,12 +1384,15 @@ Casper.prototype.open = function open(location, settings) { ...@@ -1384,12 +1384,15 @@ Casper.prototype.open = function open(location, settings) {
1384 this.page.customHeaders = utils.mergeObjects(utils.clone(baseCustomHeaders), customHeaders); 1384 this.page.customHeaders = utils.mergeObjects(utils.clone(baseCustomHeaders), customHeaders);
1385 // perfom request 1385 // perfom request
1386 this.browserInitializing = true; 1386 this.browserInitializing = true;
1387 var self = this;
1387 this.page.openUrl(this.requestUrl, { 1388 this.page.openUrl(this.requestUrl, {
1388 operation: settings.method, 1389 operation: settings.method,
1389 data: settings.data 1390 data: settings.data
1390 }, this.page.settings); 1391 }, this.page.settings, function(){
1391 // revert base custom headers 1392 // revert base custom headers
1392 this.page.customHeaders = baseCustomHeaders; 1393 self.page.customHeaders = baseCustomHeaders;
1394 });
1395
1393 return this; 1396 return this;
1394 }; 1397 };
1395 1398
......