         switch srcResp.statusCode
           when 200
             if newHeaders['content-type'] && newHeaders['content-type'].slice(0, 5) != 'image'
-              four_oh_four(resp, "Non-Image content-type returned")
+              four_oh_four(resp, "Non-Image content-type returned", url)
 
-            log newHeaders
+            debug_log newHeaders
 
             resp.writeHead srcResp.statusCode, newHeaders
             srcResp.pipe resp
           when 301, 302, 303, 307
             if remaining_redirects <= 0
-              four_oh_four(resp, "Exceeded max depth")
+              four_oh_four(resp, "Exceeded max depth", url)
             else if !srcResp.headers['location']
-              four_oh_four(resp, "Redirect with no location")
+              four_oh_four(resp, "Redirect with no location", url)
             else
               is_finished = false
               newUrl = Url.parse srcResp.headers['location']

logging_enabled = process.env.CAMO_LOGGING_ENABLED || "disabled"
connect_timeout = process.env.CAMO_CONNECT_TIMEOUT || 10

log = (msg) ->
  unless logging_enabled == "disabled"
    console.log("--------------------------------------------")
    console.log(msg)
    console.log("--------------------------------------------")

total_connections   = 0
current_connections = 0
started_at          = new Date

four_oh_four = (resp, msg) ->
  log msg
  resp.writeHead 404
  finish resp, "Not Found"


    src = Http.createClient url.port || 80, url.hostname

    src.on 'error', (error) ->
      four_oh_four(resp, "Client Request error #{error.stack}", url)

    query_path = url.pathname
    if url.query?
