         req.write(data);
     req.end();
 
-handle_resp_body = (body , callback) ->
+handle_resp_body = (body , options , callback) ->
     err = null
     try
         ret = JSON.parse body
     catch error
-        console.log "解析出错",body
+        console.log "解析出错", options.url, body
         console.log error
         err = error
         ret = null

      resp.on 'data', (chunk) ->
        body += chunk
      resp.on 'end', ->
        handle_resp_body(body, callback)
        
    req.on "error" , (e)->
        callback(null,e)


# 2 ways to call it
# url, params, callback or
# url, callback
#
http_get  = (args...) ->
  [url,params,callback] = args
  [params,callback] = [null,params] unless callback
  options =
    method : 'GET'
    url    : url
  http_request( options , params , callback)
