I am going to use Dispatch to write a simple HTTP client. I call dispatch.Http
to get a future and call the future to get the response
val request = ... val future = Http(request) // call the server asynchronously val response = future() // wait for the response from the server
Now I wonder how I can wait with timeout. I would like the last API call to be:
// throw an exception if no response received within timeout val response = future(timeout: Long)
Does it make sense ?
I understand that Dispatch
return scala.concurrent.Future
, which does not provide API with timeout. How would you suggest me implement it ?