<commit_before>Fs          = require 'fs'
Url         = require 'url'
Http        = require 'http'
Crypto      = require 'crypto'
QueryString = require 'querystring'

port        = parseInt process.env.PORT          || 8081
shared_key  = process.env.LOJACK_ASSET_PROXY_KEY || '0x24FEEDFACEDEADBEEFCAFE'

server = Http.createServer (req, resp) ->
  if req.method != 'GET' || req.url == '/'
    resp.writeHead 200
    resp.end 'hwhat'
  else if req.url == '/favicon.ico'
    resp.writeHead 200
    resp.end 'ok'
  else
    url = Url.parse req.url

    query_digest = url.pathname.replace(/^\//, '')
    query_params = QueryString.parse(url.query)

    if url.pathname?
      hmac = Crypto.createHmac("sha1", shared_key)
      hmac.update(query_params.url)
      hmac_digest = hmac.digest('hex')

      if hmac_digest == query_digest
        url = Url.parse query_params.url

        if url.host?
          src        = Http.createClient url.port || 80, url.host

          query_path = url.pathname
          if url.query?
            query_path += "?#{url.query}"

          req.headers.host = url.host
          delete(req.headers['connection'])

          srcReq = src.request 'GET', query_path, req.headers

          srcReq.on 'response', (srcResp) ->
            console.log url
            console.log srcResp.headers

            content_length = parseInt(srcResp.headers['content-length'])

            # don't pass cookies on
            delete(srcResp.headers['set-cookie'])
<commit_msg>i can't believe ie sniffs content instead of using content-type<commit_after>Fs          = require 'fs'
Url         = require 'url'
Http        = require 'http'
Crypto      = require 'crypto'
QueryString = require 'querystring'

port        = parseInt process.env.PORT          || 8081
shared_key  = process.env.LOJACK_ASSET_PROXY_KEY || '0x24FEEDFACEDEADBEEFCAFE'

server = Http.createServer (req, resp) ->
  if req.method != 'GET' || req.url == '/'
    resp.writeHead 200
    resp.end 'hwhat'
  else if req.url == '/favicon.ico'
    resp.writeHead 200
    resp.end 'ok'
  else
    url = Url.parse req.url

    query_digest = url.pathname.replace(/^\//, '')
    query_params = QueryString.parse(url.query)

    if url.pathname?
      hmac = Crypto.createHmac("sha1", shared_key)
      hmac.update(query_params.url)
      hmac_digest = hmac.digest('hex')

      if hmac_digest == query_digest
        url = Url.parse query_params.url

        if url.host?
          src        = Http.createClient url.port || 80, url.host

          query_path = url.pathname
          if url.query?
            query_path += "?#{url.query}"

          req.headers.host = url.host
          delete(req.headers['connection'])

          srcReq = src.request 'GET', query_path, req.headers

          srcReq.on 'response', (srcResp) ->
            console.log url
            console.log srcResp.headers

            content_length = parseInt(srcResp.headers['content-length'])

            # don't pass cookies on
            delete(srcResp.headers['set-cookie'])
            srcResp.headers['X-Content-Type-Options'] = 'nosniff'

{'fraction_non_alphanumeric': 0.12001287001287002, 'fraction_numerical': 0.010296010296010296, 'mean_word_length': 2.191991786447639, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4174225', 'n_tokens_mistral': 1033, 'n_tokens_neox': 972, 'n_words': 209}