<commit_before># https://raw.github.com/plessbd/superagent/f6e7a85555bbd1a70babf62b4d0c0ec674f3d2f5/lib/node/index.js
Tower.start = (port, callback) ->
  if typeof port == 'function'
    callback  = port
    port      = undefined

  Tower.port  = port || 3010
  Tower.Application.instance().server.listen Tower.port, callback

Tower.startWithSocket = (port, callback) ->
  if typeof port == 'function'
    callback  = port
    port      = undefined

  Tower.port  = port || 3010
  app         = Tower.Application.instance()
  app.io      = require('socket.io').listen(app.server, log: false)
  app.io.set('client store expiration', 0)
  app.io.set('log level', -1)
  #app.io.set("transports", ["websocket"])
  app.server.listen Tower.port, callback

Tower.stop = ->
  Tower.port = 3010
  delete Tower.Controller.testCase
  Tower.Application.instance().server.close()

Tower.modules.superagent.Request::make = (callback) ->
  @end (response) ->
    controller = Tower.Controller.testCase
    if controller
      response.controller = controller
      callback.call controller, response
    else
      callback.call @, response

_.get     = ->
  _.request "get", arguments...

_.post    = ->
  _.request "post", arguments...

_.head    = ->
  _.request "head", arguments...

_.put     = ->
  _.request "put", arguments...

_.destroy = ->
  _.request "del", arguments...

_.request = (method, path, options, callback) ->
  if typeof options == "function"
    callback  = options
    options   = {}
  options   ||= {}
  headers     = options.headers || {}
  params      = options.params  || {}
  redirects   = options.redirects || 5
  auth        = options.auth
  format      = options.format# || "form-data"

  newRequest = Tower.modules.superagent[method.toLowerCase()]("http://localhost:#{Tower.port}#{path}")
    .set(headers)
    .send(params)
    .redirects(redirects)

  newRequest = newRequest.auth(auth.username, auth.password) if auth

  newRequest = newRequest.type(format) if format

  if callback
    newRequest.make(callback)
  else
    newRequest

<commit_msg>fixes not being able to stop redirect using helper functions<commit_after># https://raw.github.com/plessbd/superagent/f6e7a85555bbd1a70babf62b4d0c0ec674f3d2f5/lib/node/index.js
Tower.start = (port, callback) ->
  if typeof port == 'function'
    callback  = port
    port      = undefined

  Tower.port  = port || 3010
  Tower.Application.instance().server.listen Tower.port, callback

Tower.startWithSocket = (port, callback) ->
  if typeof port == 'function'
    callback  = port
    port      = undefined

  Tower.port  = port || 3010
  app         = Tower.Application.instance()
  app.io      = require('socket.io').listen(app.server, log: false)
  app.io.set('client store expiration', 0)
  app.io.set('log level', -1)
  #app.io.set("transports", ["websocket"])
  app.server.listen Tower.port, callback

Tower.stop = ->
  Tower.port = 3010
  delete Tower.Controller.testCase
  Tower.Application.instance().server.close()

Tower.modules.superagent.Request::make = (callback) ->
  @end (response) ->
    controller = Tower.Controller.testCase
    if controller
      response.controller = controller
      callback.call controller, response
    else
      callback.call @, response

_.get     = ->
  _.request "get", arguments...

_.post    = ->
  _.request "post", arguments...

_.head    = ->
  _.request "head", arguments...

_.put     = ->
  _.request "put", arguments...

_.destroy = ->
  _.request "del", arguments...

_.request = (method, path, options, callback) ->
  if typeof options == "function"
    callback  = options
    options   = {}
  options   ||= {}
  headers     = options.headers || {}
  params      = options.params  || {}
  redirects   = if options.redirects? then options.redirects else 5
  auth        = options.auth
  format      = options.format# || "form-data"

  newRequest = Tower.modules.superagent[method.toLowerCase()]("http://localhost:#{Tower.port}#{path}")
    .set(headers)
    .send(params)
    .redirects(redirects)

  newRequest = newRequest.auth(auth.username, auth.password) if auth

  newRequest = newRequest.type(format) if format

  if callback
    newRequest.make(callback)
  else
    newRequest


{'fraction_non_alphanumeric': 0.14082503556187767, 'fraction_numerical': 0.017069701280227598, 'mean_word_length': 2.950374531835206, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, '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': '3928981', 'n_tokens_mistral': 1366, 'n_tokens_neox': 1330, 'n_words': 287}