Skip to content

Instantly share code, notes, and snippets.

@thom4parisot
Created July 17, 2012 13:58
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thom4parisot/3129526 to your computer and use it in GitHub Desktop.
Save thom4parisot/3129526 to your computer and use it in GitHub Desktop.
Dump Response Headers with CasperJS
var casper = require('casper').create();
casper.start();
casper.open('http://borisschapira.com/');
casper.then(function dumpHeaders(){
this.currentResponse.headers.forEach(function(header){
console.log(header.name +': '+ header.value);
});
});
casper.run(function(){
this.exit();
});
@ldong
Copy link

ldong commented Jun 9, 2014

Nice to know, thank you.

Here's another one for look up what is in the cookies of current session:

var cookies = JSON.stringify(phantom.cookies)
console.log('Cookies: '+ cookies);

@tasfiahm
Copy link

I am using phantom js as well as caspersj. I am trying to do it like this to display the cookies:

var url = 'https://google.com';
casper.thenOpen(Url, function() {
var cookies = page.cookies;
console.log('Listing cookies:');
for(var i in cookies) {
console.log(cookies[i].name + '=' + cookies[i].value);
};
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment