   jar.add = jar.setCookie
   jar.get = (uri) -> jar.getCookies url.parse uri
   jar
-
 quest.cookie = cookiejar.Cookie
-
 module.exports = quest
    options.headers['content-type'] = 'application/json'
    options.body = JSON.stringify options.json
  jar: (options) ->
    cookies = options.jar.getCookies options
    cookie_string = _(cookies).map (c) -> c.toValueString()
    cookie_string = cookie_string.join '; '
    options.headers.cookie = if not options.headers.cookie? then '' else "#{options.headeers.cookie}; "
    options.headers.cookie = "#{options.headers.cookie}#{cookie_string}"

is_uri = (uri) -> /^https?:\/\//.test uri
normalize_uri = (options) -> options.uri = "http://#{options.uri}" if not is_uri options.uri

handle_options = (options) -> _(_(handle).values()).map (handler) -> handler options

should_redirect = (options, resp) ->
  299 < resp.statusCode < 400 and (options.followAllRedirects or (options.followRedirects and

  _(options).defaults parsed_uri
  _(options.headers).defaults
    'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_3) AppleWebKit/537.16 (KHTML, like Gecko) Chrome/24.0.1297.0 Safari/537.16'
  handle_options options
  if options.body?
    options.body = new Buffer options.body
    options.headers['content-length'] = options.body.length
  options.method = options.method.toUpperCase()

  req = request_module.request options, (resp) ->
    resp.request = _(_({}).extend(req)).extend options

    cookies = resp?.headers?['set-cookie']
    if options.jar isnt false and cookies?
      options.jar.setCookies if _(cookies).isArray() then cookies else [cookies]
    if should_redirect options, resp
      return req.emit 'error', 'Exceeded max redirects' if options.maxRedirects is 0
      redirect_options = {}
