From 6874e55a316e4fe8a650efd3a849814a91bba8cb Mon Sep 17 00:00:00 2001 From: Piotr Gabara Date: Wed, 6 Sep 2017 19:09:16 +0200 Subject: Post review changes --- README.md | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 3c615db..53a8567 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ val query = "http language:scala" // `sort` is removed, as the value is not defined val request = sttp.get(uri"https://api.github.com/search/repositories?q=$query&sort=$sort") -implicit val handler = HttpURLConnectionHandler +implicit val handler = HttpURLConnectionHandler() val response = request.send() // response.header(...): Option[String] @@ -61,7 +61,7 @@ experimenting with sttp by copy-pasting the following: ```scala import $ivy.`com.softwaremill.sttp::core:0.0.11` import com.softwaremill.sttp._ -implicit val handler = HttpURLConnectionHandler +implicit val handler = HttpURLConnectionHandler() sttp.get(uri"http://httpbin.org/ip").send() ``` @@ -113,7 +113,7 @@ value of type `SttpHandler` needs to be in scope to invoke the `send()` on the request: ```scala -implicit val handler = HttpURLConnectionHandler +implicit val handler = HttpURLConnectionHandler() val response: Response[String] = request.send() ``` @@ -214,7 +214,7 @@ in the identity type constructor, which is equivalent to no wrapper at all. To use, add an implicit value: ```scala -implicit val sttpHandler = HttpURLConnectionHandler +implicit val sttpHandler = HttpURLConnectionHandler() ``` ### `AkkaHttpHandler` @@ -409,7 +409,7 @@ a request to decode the response to a specific object. import com.softwaremill.sttp._ import com.softwaremill.sttp.circe._ -implicit val handler = HttpURLConnectionHandler +implicit val handler = HttpURLConnectionHandler() // Assume that there is an implicit circe encoder in scope // for the request Payload, and a decoder for the Response @@ -454,6 +454,26 @@ There are two type aliases for the request template that are used: * `type Request[T, S] = RequestT[Id, T, S]`. A sendable request. * `type PartialRequest[T, S] = RequestT[Empty, T, S]` +## Timeouts + +Sttp supports read and connection timeouts: + * Connection timeout - can be set globally (30 seconds by default) + * Read timeout - can be set per request (1 minute by default) + +How to use: +```scala +import com.softwaremill.sttp._ +import scala.concurrent.duration._ + +// all backends provide a constructor that allows users to specify connection timeout +implicit val handler = HttpURLConnectionHandler(connectionTimeout = 1.minute) + +sttp + .get(uri"...") + .readTimeout(5.minutes) // or Duration.Inf to turn read timeout off + .send() +``` + ## Notes * the encoding for `String`s defaults to `utf-8`. @@ -486,3 +506,4 @@ and pick a task you'd like to work on! * [Omar Alejandro Mainegra Sarduy](https://github.com/omainegra) * [Bjørn Madsen](https://github.com/aeons) * [Piotr Buda](https://github.com/pbuda) +* [Piotr Gabara](https://github.com/bhop) -- cgit v1.2.3