<commit_before>'use strict';
var tape = require('tape');
var got = require('../');
var server = require('./server.js');
var s = server.createServer();

s.on('/finite', function (req, res) {
	res.writeHead(302, {
		location: s.url + '/'
	});
	res.end();
});

s.on('/endless', function (req, res) {
	res.writeHead(302, {
		location: s.url + '/endless'
	});
	res.end();
});

s.on('/relative', function (req, res) {
	res.writeHead(302, {
		location: '/'
	});
	res.end();
});

s.on('/', function (req, res) {
	res.end('reached');
});

tape('setup', function (t) {
	s.listen(s.port, function () {
		t.end();
	});
});

tape('follows redirect', function (t) {
	got(s.url + '/finite', function (err, data) {
		t.error(err);
		t.equal(data, 'reached');
		t.end();
	});
});

tape('follows relative redirect', function (t) {
	got(s.url + '/relative', function (err, data) {
		t.error(err);
		t.equal(data, 'reached');
		t.end();
	});
});

tape('throws on endless redirect', function (t) {
	got(s.url + '/endless', function (err) {
		t.ok(err, 'should get error');
		t.equal(err.message, 'Redirected 10 times. Aborting.');
		t.end();
	});
});

tape('cleanup', function (t) {
	s.close();
	t.end();
});<commit_msg>add test on host+port in options<commit_after>'use strict';
var tape = require('tape');
var got = require('../');
var server = require('./server.js');
var s = server.createServer();

s.on('/finite', function (req, res) {
	res.writeHead(302, {
		location: s.url + '/'
	});
	res.end();
});

s.on('/endless', function (req, res) {
	res.writeHead(302, {
		location: s.url + '/endless'
	});
	res.end();
});

s.on('/relative', function (req, res) {
	res.writeHead(302, {
		location: '/'
	});
	res.end();
});

s.on('/', function (req, res) {
	res.end('reached');
});

tape('setup', function (t) {
	s.listen(s.port, function () {
		t.end();
	});
});

tape('follows redirect', function (t) {
	got(s.url + '/finite', function (err, data) {
		t.error(err);
		t.equal(data, 'reached');
		t.end();
	});
});

tape('follows relative redirect', function (t) {
	got(s.url + '/relative', function (err, data) {
		t.error(err);
		t.equal(data, 'reached');
		t.end();
	});
});

tape('throws on endless redirect', function (t) {
	got(s.url + '/endless', function (err) {
		t.ok(err, 'should get error');
		t.equal(err.message, 'Redirected 10 times. Aborting.');
		t.end();
	});
});

tape('host+path in options are not breaking redirects', function (t) {
	got(s.url + '/relative', {host: s.url, path: '/relative'}, function (err, data) {
		t.error(err);
		t.equal(data, 'reached');
		t.end();
	});
});

tape('cleanup', function (t) {
	s.close();
	t.end();
});
{'fraction_non_alphanumeric': 0.2515174506828528, 'fraction_numerical': 0.00834597875569044, 'mean_word_length': 3.820840950639854, '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': '5404330', 'n_tokens_mistral': 1083, 'n_tokens_neox': 1037, 'n_words': 229}