<commit_before>var test = require('tap').test;
var http = require('http');
var net = require('net');
var bouncy = require('../');

test('check for x-forwarded default headers', function (t) {
    t.plan(6);
    
    var p0 = Math.floor(Math.random() * (Math.pow(2,16) - 1e4) + 1e4);
    var s0 = http.createServer(function (req, res) {
        res.setHeader('content-type', 'text/plain');
        res.write('beep boop');
        t.equal(req.headers['x-forwarded-for'], '127.0.0.1');
        t.equal(req.headers['x-forwarded-port'], p1.toString());
        t.equal(req.headers['x-forwarded-proto'], 'http');
        res.end();
    });
    s0.listen(p0, connect);
    
    var p1 = Math.floor(Math.random() * (Math.pow(2,16) - 1e4) + 1e4);
    var s1 = bouncy(function (req, bounce) { bounce(p0) });
    s1.listen(p1, connect);
    <commit_msg>explicitly set and send x- headers, x_headers test now passes<commit_after>var test = require('tap').test;
var http = require('http');
var net = require('net');
var bouncy = require('../');

test('check for x-forwarded default headers', function (t) {
    t.plan(6);
    
    var p0 = Math.floor(Math.random() * (Math.pow(2,16) - 1e4) + 1e4);
    var s0 = http.createServer(function (req, res) {
        res.setHeader('content-type', 'text/plain');
        res.write('beep boop');
        t.equal(req.headers['x-forwarded-for'], '127.0.0.1');
        t.equal(req.headers['x-forwarded-port'], p1.toString());
        t.equal(req.headers['x-forwarded-proto'], 'http');
        res.end();
    });
    s0.listen(p0, connect);
    
    var p1 = Math.floor(Math.random() * (Math.pow(2,16) - 1e4) + 1e4);
    var s1 = bouncy(function (req, bounce) {
        bounce({
            port: p0,
            headers: {
                'x-forwarded-for': '127.0.0.1',
                'x-forwarded-port': p1.toString(),
                'x-forwarded-proto': 'http'
            }
        });
    });
    s1.listen(p1, connect);
    
{'fraction_non_alphanumeric': 0.19785276073619631, 'fraction_numerical': 0.0352760736196319, 'mean_word_length': 2.5134649910233393, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3578067', 'n_tokens_mistral': 733, 'n_tokens_neox': 706, 'n_words': 134}