Http Client is now lazy init.

This commit is contained in:
Clinton Alexander 2016-07-08 10:48:55 +01:00
parent 01e64d3030
commit 639df4dcb9

View File

@ -7,9 +7,11 @@ import java.util.concurrent.TimeUnit
/**
* A small set of utilities for making HttpCalls, aimed at demos.
*/
private val client = OkHttpClient.Builder()
private val client by lazy {
OkHttpClient.Builder()
.connectTimeout(5, TimeUnit.SECONDS)
.readTimeout(60, TimeUnit.SECONDS).build();
}
fun putJson(url: URL, data: String) : Boolean {
val body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), data)