1

I m using dispatch-nio library to make several Http request calls. But I cannot find an example how to handle callback responses through nio library.

And also I am unable to handle exceptions thrown by nio.Http call. Could anyone please post an example or an url where we can find some information of it.

So far I achieved:

    val http = new nio.Http
    withShutdown(http) {

    val host = :/("http://example.org") /"api"
    val withParams = host <<? Map(      
      "page" -> "1"
    )
      val future = http(withParams as_str)

       while (!future.isSet) { 
          println("Waiting for results...")
          Thread.sleep(15000)
       }

      future.apply()
    }

  }

How to set headers and onComplete? any example please

Thanks in advance.

DSKVP
  • 663
  • 2
  • 11
  • 19
  • What have you tried so far? You can find the documentation here: http://dispatch-classic.databinder.net/Response+Bodies.html – Callum May 20 '15 at 08:56
  • val http = new nio.Http withShutdown(http) { val host = url("http://scala.org") val withParams = host < Map( "page" -> "1" ) val future = http(withParams as_str) while (!future.isSet) { println("Waiting for results...") Thread.sleep(15000) } future.apply() } } – DSKVP May 20 '15 at 09:11
  • Always it return status 500: service temporarily unavailable. How can we set the headers to the request? – DSKVP May 20 '15 at 09:12

0 Answers0