zombie icon indicating copy to clipboard operation
zombie copied to clipboard

Retrieve Server HTTP Headers

Open joswr1ght opened this issue 10 years ago • 4 comments

The documentation describes ways to set Cookie and Referrer values, but how can we retrieve the values set by the server?

var Browser = require('zombie'),
    assert = require('chai').assert;
var browser;

suite('Server Response Test', function() {
    setup(function() {
        browser = new Browser;
    });
    test('validate server response', function(done) {
       var link = 'http://localhost:3000/';
       browser.visit(link, function() {
           browser.clickLink('.googleLink',
               function() {
                   assert(browser.field('referrer').value === link);
                   done();
           });
       });
    });
});

I'm using Mocha here, but I'm not sure how to get the HTTP server headers. This example is contrived, returning null for browser.field('referrer').value. Ideally, I'd like to get HTTP Server, "Referer", Last-Modified, Connection, Cache-Control, etc.

Thanks!

joswr1ght avatar Jul 07 '15 12:07 joswr1ght

Have a look at resources: http://zombie.js.org/#resources

assaf avatar Jul 07 '15 15:07 assaf

I get the same problem... it's always null. still repro on the latest version

dreambo8563 avatar Nov 04 '15 11:11 dreambo8563

@dreambo8563 The fix is provided by YoussefKababe's change. I don't know if or when it will be merged into master, but making his change locally seems to fix the issue for me.

shadefinale avatar Nov 14 '15 01:11 shadefinale

Experiencing this bug. Waiting for #947 to be pulled.

In the mean time, using browser.resources[0].request.headers._headers[0][1] to get the referer field

kas avatar Apr 06 '17 12:04 kas