diff options
author | Piotr Gabara <piotr.gabara@hotmail.com> | 2017-09-06 19:09:16 +0200 |
---|---|---|
committer | Piotr Gabara <piotr.gabara@hotmail.com> | 2017-09-06 19:20:17 +0200 |
commit | 6874e55a316e4fe8a650efd3a849814a91bba8cb (patch) | |
tree | e22fa85abb61805b2d8f363b0e55eac1d60a94f3 /core | |
parent | e82346820797bb2d80d0fada7f17c5880871edce (diff) | |
download | sttp-6874e55a316e4fe8a650efd3a849814a91bba8cb.tar.gz sttp-6874e55a316e4fe8a650efd3a849814a91bba8cb.tar.bz2 sttp-6874e55a316e4fe8a650efd3a849814a91bba8cb.zip |
Post review changes
Diffstat (limited to 'core')
4 files changed, 12 insertions, 13 deletions
diff --git a/core/src/main/scala/com/softwaremill/sttp/HttpURLConnectionHandler.scala b/core/src/main/scala/com/softwaremill/sttp/HttpURLConnectionHandler.scala index 24c81c7..9b73298 100644 --- a/core/src/main/scala/com/softwaremill/sttp/HttpURLConnectionHandler.scala +++ b/core/src/main/scala/com/softwaremill/sttp/HttpURLConnectionHandler.scala @@ -21,7 +21,7 @@ class HttpURLConnectionHandler private (connectionTimeout: FiniteDuration) c.setRequestMethod(r.method.m) r.headers.foreach { case (k, v) => c.setRequestProperty(k, v) } c.setDoInput(true) - c.setReadTimeout(timeout(r.readTimeout)) + c.setReadTimeout(timeout(r.options.readTimeout)) c.setConnectTimeout(timeout(connectionTimeout)) // redirects are handled in SttpHandler diff --git a/core/src/main/scala/com/softwaremill/sttp/RequestT.scala b/core/src/main/scala/com/softwaremill/sttp/RequestT.scala index b9b49f4..e4fd421 100644 --- a/core/src/main/scala/com/softwaremill/sttp/RequestT.scala +++ b/core/src/main/scala/com/softwaremill/sttp/RequestT.scala @@ -34,7 +34,6 @@ case class RequestT[U[_], T, +S]( body: RequestBody[S], headers: Seq[(String, String)], response: ResponseAs[T, S], - readTimeout: Duration, options: RequestOptions, tags: Map[String, Any] ) { @@ -218,7 +217,7 @@ case class RequestT[U[_], T, +S]( copy[U, T, S2](body = StreamBody(b)) def readTimeout(t: Duration): RequestT[U, T, S] = - copy(readTimeout = t) + this.copy(options = options.copy(readTimeout = t)) def response[T2, S2 >: S](ra: ResponseAs[T2, S2]): RequestT[U, T2, S2] = this.copy(response = ra) @@ -280,4 +279,4 @@ class SpecifyAuthScheme[U[_], T, +S](hn: String, rt: RequestT[U, T, S]) { rt.header(hn, s"Bearer $token") } -case class RequestOptions(followRedirects: Boolean) +case class RequestOptions(followRedirects: Boolean, readTimeout: Duration) diff --git a/core/src/main/scala/com/softwaremill/sttp/package.scala b/core/src/main/scala/com/softwaremill/sttp/package.scala index 4ec1331..a9950be 100644 --- a/core/src/main/scala/com/softwaremill/sttp/package.scala +++ b/core/src/main/scala/com/softwaremill/sttp/package.scala @@ -58,14 +58,14 @@ package object sttp { * An empty request with no headers. */ val emptyRequest: RequestT[Empty, String, Nothing] = - RequestT[Empty, String, Nothing](None, - None, - NoBody, - Vector(), - asString, - DefaultReadTimeout, - RequestOptions(followRedirects = true), - Map()) + RequestT[Empty, String, Nothing]( + None, + None, + NoBody, + Vector(), + asString, + RequestOptions(followRedirects = true, readTimeout = DefaultReadTimeout), + Map()) /** * A starting request, with the following modifications comparing to diff --git a/core/src/test/scala/com/softwaremill/sttp/RequestTests.scala b/core/src/test/scala/com/softwaremill/sttp/RequestTests.scala index 6332467..e62112a 100644 --- a/core/src/test/scala/com/softwaremill/sttp/RequestTests.scala +++ b/core/src/test/scala/com/softwaremill/sttp/RequestTests.scala @@ -68,6 +68,6 @@ class RequestTests extends FlatSpec with Matchers { } "request timeout" should "use default if not overridden" in { - sttp.readTimeout should be(DefaultReadTimeout) + sttp.options.readTimeout should be(DefaultReadTimeout) } } |