 # 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 = 
+  options =
     method : 'GET'
     url    : url
   http_request( options , params , callback)

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


        req.write(data);
    req.end();

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