package com.icloud.server.utils.http
import scala.collection.JavaConverters._
object Net {

  import scalaj.http._

  def run (url: String, requestJson: String) = {
    val startTime = System.currentTimeMillis()
    val r = Http( url ).timeout( connTimeoutMs = 10000, readTimeoutMs = 20000 ).header( "Content-Type", "application/json; charset=utf8" ).postData( requestJson ).asString
    val endTime = System.currentTimeMillis()
    val allCost = endTime - startTime //    pdbDebug.debug(s"id:${impId}|dsp:${dsp.getName}==>${requestJson}")
    //    pdbDebug.debug(s"id:${impId}|dsp:${dsp.getName}| cost: $allCost| httpcode: ${r.code} :<==${r.body.replaceAll("\n", "").replaceAll("\r", "")}")
    (r.code, r.body)
  }
}
