<commit_before>var test = require('tape');
var url = require('url');
var path = require('path');
var curli = require(path.join(__dirname, '..'));
var server = require(path.join(__dirname, './server.js')).createServer();

server.listen(0, function() {
  var port = server.address().port;
  var host = '//localhost:' + port;
  var href = 'http:' + host + '/';
  var options = url.parse(href);
  var testHeaders = {
    'content-type': 'application/json; charset=UTF-8'
  };

  server.on('/', function(req, res) {
    res.writeHead(200, testHeaders);
    res.end();
  });

  test('Full url as string', function(t) {
    curli(href, function(err, headers) {
      t.error(err, 'Shouldn\'t error');
      t.ok(headers, 'Headers sent');
      t.equal(headers['content-type'], testHeaders['content-type'], '\'Content-Type\' header set');
      t.end();
    });
  });

  test('url.parse()\'d url string', function(t) {
    curli(options, function(err, headers) {
      t.error(err, 'Shouldn\'t error');
      t.ok(headers, 'Headers sent');
      t.equal(headers['content-type'], testHeaders['content-type'], '\'Content-Type\' header set');
      server.close();
      t.end();
    });
  });
});<commit_msg>Update standard http tests, with the addition of method checks<commit_after>var test = require('tape');
var url = require('url');
var path = require('path');
var curli = require(path.join(__dirname, '..'));
var testServer = require(path.join(__dirname, 'server.js'));

test('Request method', function(t) {
  var server = testServer.createServer();

  t.test('Ensure HEAD request is made', function(t) {
    server.listen(0, function() {
      var port = server.address().port;
      var host = '//localhost:' + port;
      var href = 'http:' + host + '/';

      server.on('/', function(req, res) {
        t.equal(req.method, 'HEAD', 'Request method should be "HEAD"');
        res.writeHead(200);
        res.end();
      });

      curli(href, function(err, headers) {
        t.error(err, 'Shouldn\'t error');
        server.close();
        t.end();
      });
    });
  });

  t.test('Cannot override default request method', function(t) {
    server.listen(0, function() {
      var port = server.address().port;
      var host = '//localhost:' + port;
      var href = 'http:' + host + '/';
      var options = url.parse(href);
      options.method = 'GET';

      server.on('/', function(req, res) {
        t.equal(req.method, 'HEAD', 'Request method should be "HEAD"');
        t.notEqual(req.method, 'GET', 'Request method should not be "GET"');
        res.writeHead(200);
        res.end();
      });

      curli(options, function(err, headers) {
        t.error(err, 'Shouldn\'t error');
        server.close();
        t.end();
      });
    });
  });
});

test('Standard http requests', function(t) {
  var server = testServer.createServer();

  server.listen(0, function() {
    var port = server.address().port;
    var host = '//localhost:' + port;
    var href = 'http:' + host + '/';
    var options = url.parse(href);
    var testHeaders = {
      'content-type': 'application/json; charset=UTF-8'
    };

    server.on('/', function(req, res) {
      res.writeHead(200, testHeaders);
      res.end();
    });

    t.test('Full url as string', function(t) {
      curli(href, function(err, headers) {
        t.error(err, 'Shouldn\'t error');
        t.ok(headers, 'Headers sent');
        t.equal(headers['content-type'], testHeaders['content-type'], '\'Content-Type\' header set');
        t.end();
      });
    });

    t.test('url.parse()\'d url string', function(t) {
      curli(options, function(err, headers) {
        t.error(err, 'Shouldn\'t error');
        t.ok(headers, 'Headers sent');
        t.equal(headers['content-type'], testHeaders['content-type'], '\'Content-Type\' header set');
        server.close();
        t.end();
      });
    });
  });
});
{'fraction_non_alphanumeric': 0.19809866392600206, 'fraction_numerical': 0.0046248715313463515, 'mean_word_length': 2.8204121687929344, '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': '1319604', 'n_tokens_mistral': 1252, 'n_tokens_neox': 1229, 'n_words': 279}