<commit_before>casper.test.comment('Casper.getCurrentHeader()');

var server = require('webserver').create();
var service = server.listen(8090, function (request, response) {
    response.statusCode = 200;
    response.headers = {
        'Content-Language': 'en',
        'Content-Type': 'text/html',
        'Date': new Date().toUTCString()
    };
    response.write("\o/");
    response.close();
});

function dumpHeaders () {
    casper.test.comment('Dumping current response headers');

    casper.getCurrentHeaders().forEach(function (header) {
        casper.test.comment('- ' + header.name + ': ' + header.value);
    });
}

casper.start('tests/site/index.html', function thenLocalPage () {
    this.test.assertEquals(casper.getCurrentHeader('Status'), null, 'No Status header on local page');
    this.test.assertEquals(casper.getCurrentHeader('Content-Language'), null, 'No Content-Language on local page');
    this.test.assert(casper.getCurrentHeaders().length === 0, 'No headers sent back');
});

casper.thenOpen('http://localhost:8090/', function thenLocalhost () {
    this.test.assertEquals(casper.getCurrentHeader('Content-Language'), 'en', 'Checking existing header');
    this.test.assertEquals(casper.getCurrentHeader('content-language'), null, 'Checking header typecase');
    this.test.assertEquals(casper.getCurrentHeader('X-Is-Troll'), null, 'Checking unexisting header');<commit_msg>Tests for the new API<commit_after>casper.test.comment('Casper.headers.get()');

var server = require('webserver').create();
var service = server.listen(8090, function (request, response) {
    response.statusCode = 200;
    response.headers = {
        'Content-Language': 'en',
        'Content-Type': 'text/html',
        'Date': new Date().toUTCString()
    };
    response.write("\o/");
    response.close();
});

function dumpHeaders () {
    casper.test.comment('Dumping current response headers');

    casper.currentResponse.headers.forEach(function (header) {
        casper.test.comment('- ' + header.name + ': ' + header.value);
    });
}

casper.start('tests/site/index.html', function thenLocalPage () {
    this.test.assertEquals(casper.currentResponse, undefined, 'No response available on local page');
});

casper.thenOpen('http://localhost:8090/', function thenLocalhost () {
    var headers = casper.currentResponse.headers;

    this.test.assertEquals(headers.get('Content-Language'), 'en', 'Checking existing header');
    this.test.assertEquals(headers.get('content-language'), null, 'Checking header typecase');
    this.test.assertEquals(headers.get('X-Is-Troll'), null, 'Checking unexisting header');
{'fraction_non_alphanumeric': 0.16590736522399394, 'fraction_numerical': 0.008731966590736523, 'mean_word_length': 4.43298969072165, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1858087', 'n_tokens_mistral': 774, 'n_tokens_neox': 757, 'n_words': 143}