<commit_before>var carcass = require('carcass');
var should = require('should');
var request = require('request');

var server = require('./fixture').server;

describe('Cross-origin resource sharing', function() {
    before(function(done) {
        server.mount('applications/cors');
        server.mount('applications/restify');
        server.mount('applications/lorem', '/cors');
        server.start(done);
    });

    after(function(done) {
        server.close(done);
    });

    describe('HEAD /cors/dolor', function() {
        it('should return the headers', function(done) {
            request.head({
                uri: 'http://127.0.0.1:3000/cors/dolor',
                headers: {
                    Origin: 'http://lorem.ipsum'
                }
            }, function(err, res, body) {
                should.not.exist(err);
                res.should.be.a('object');
                res.should.have.property('statusCode', 200);
                res.should.not.have.property('body');
                res.should.have.property('headers');
                var headers = res.headers;
                headers.should.be.a('object');
                headers.should.have.property('access-control-allow-origin');
                headers.should.have.property('access-control-allow-methods');
                headers.should.have.property('access-control-allow-headers');
                headers.should.have.property('content-type');
                headers.should.have.property('content-length');
                setTimeout(done, 1);<commit_msg>Fixed CORS test; HEAD returns an empty body.<commit_after>var carcass = require('carcass');
var should = require('should');
var request = require('request');

var server = require('./fixture').server;

describe('Cross-origin resource sharing', function() {
    before(function(done) {
        server.mount('applications/cors');
        server.mount('applications/restify');
        server.mount('applications/lorem', '/cors');
        server.start(done);
    });

    after(function(done) {
        server.close(done);
    });

    describe('GET /cors/dolor', function() {
        it('should return the body', function(done) {
            request.get({
                uri: 'http://127.0.0.1:3000/cors/dolor',
                headers: {
                    Origin: 'http://lorem.ipsum'
                }
            }, function(err, res, body) {
                should.not.exist(err);
                res.should.be.a('object');
                res.should.have.property('statusCode', 200);
                res.should.have.property('body', 'Lorem ipsum dolor sit amet');
                res.should.have.property('headers');
                var headers = res.headers;
                headers.should.be.a('object');
                headers.should.have.property('access-control-allow-origin');
                headers.should.have.property('access-control-allow-methods');
                headers.should.have.property('access-control-allow-headers');
                headers.should.have.property('content-type');
                headers.should.have.property('content-length');
                setTimeout(done, 1);
            });
        });
    });

    describe('HEAD /cors/dolor', function() {
        it('should return the headers', function(done) {
            request.head({
                uri: 'http://127.0.0.1:3000/cors/dolor',
                headers: {
                    Origin: 'http://lorem.ipsum'
                }
            }, function(err, res, body) {
                should.not.exist(err);
                res.should.be.a('object');
                res.should.have.property('statusCode', 200);
                res.should.have.property('body', '');
                res.should.have.property('headers');
                var headers = res.headers;
                headers.should.be.a('object');
                headers.should.have.property('access-control-allow-origin');
                headers.should.have.property('access-control-allow-methods');
                headers.should.have.property('access-control-allow-headers');
                headers.should.have.property('content-type');
                headers.should.have.property('content-length');
                setTimeout(done, 1);
{'fraction_non_alphanumeric': 0.15194927195866603, 'fraction_numerical': 0.00986378581493659, 'mean_word_length': 1.8699460916442048, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 3, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7035823', 'n_tokens_mistral': 1195, 'n_tokens_neox': 1103, 'n_words': 161}