<commit_before>--[[lit-meta
  name = "creationix/coro-http"
  version = "3.2.1"
  dependencies = {
    "creationix/coro-net@3.3.0",
    "luvit/http-codec@3.0.0"
  }
  homepage = "https://github.com/luvit/lit/blob/master/deps/coro-http.lua"
  description = "An coro style http(s) client and server helper."
  tags = {"coro", "http"}
  license = "MIT"
  author = { name = "<NAME>" }
]]

local httpCodec = require('http-codec')
local net = require('coro-net')

local function createServer(host, port, onConnect)
  return net.createServer({
    host = host,
    port = port,
    encoder = httpCodec.encoder,
    decoder = httpCodec.decoder,
  }, function (read, write, socket)
    for head in read do
      local parts = {}
      for part in read do
        if #part > 0 then
          parts[#parts + 1] = part
        else
          break
        end
      end
      local body = table.concat(parts)
      head, body = onConnect(head, body, socket)
      write(head)
      if body then write(body) end
      write("")
      if not head.keepAlive then break end
    end
  end)
end

local function parseUrl(url)
  local protocol, host, hostname, port, path = url:match("^(https?:)//(([^/:]+):?([0-9]*))(/?.*)$")
  if not protocol then error("Not a valid http url: " .. url) end
  local tls = protocol == "https:"<commit_msg>Fix coro-http server to close the socket when done<commit_after>--[[lit-meta
  name = "creationix/coro-http"
  version = "3.2.2"
  dependencies = {
    "creationix/coro-net@3.3.0",
    "luvit/http-codec@3.0.0"
  }
  homepage = "https://github.com/luvit/lit/blob/master/deps/coro-http.lua"
  description = "An coro style http(s) client and server helper."
  tags = {"coro", "http"}
  license = "MIT"
  author = { name = "<NAME>" }
]]

local httpCodec = require('http-codec')
local net = require('coro-net')

local function createServer(host, port, onConnect)
  return net.createServer({
    host = host,
    port = port,
    encoder = httpCodec.encoder,
    decoder = httpCodec.decoder,
  }, function (read, write, socket)
    for head in read do
      local parts = {}
      for part in read do
        if #part > 0 then
          parts[#parts + 1] = part
        else
          break
        end
      end
      local body = table.concat(parts)
      head, body = onConnect(head, body, socket)
      write(head)
      if body then write(body) end
      write("")
      if not head.keepAlive then break end
    end
    write()
  end)
end

local function parseUrl(url)
  local protocol, host, hostname, port, path = url:match("^(https?:)//(([^/:]+):?([0-9]*))(/?.*)$")
  if not protocol then error("Not a valid http url: " .. url) end
  local tls = protocol == "https:"
{'fraction_non_alphanumeric': 0.14998139188686266, 'fraction_numerical': 0.009676218831410495, 'mean_word_length': 2.6472184531886023, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '2835904', 'n_tokens_mistral': 922, 'n_tokens_neox': 907, 'n_words': 256}