For debugging purporses I need to see the whole request: headers and data. How can I achieve this?
Casper (well, actually PhantomJS) supplies two callbacks, one when the resource is requested (where you can see headers being sent), and one when response is received (so you can see the headers the server replied with):
var utils = require('utils');
var casper = require('casper').create();
casper.options.onResourceRequested = function(C, requestData, request) {
utils.dump(requestData.headers);
};
casper.options.onResourceReceived = function(C, response) {
utils.dump(response.headers);
};
(Using utils
module is optional, it just gives nice human-readable formatting. Thanks to thelogix and AlanChavez for the suggestion in the comments.)