diff options
author | adamw <adam@warski.org> | 2017-09-14 11:03:21 +0100 |
---|---|---|
committer | adamw <adam@warski.org> | 2017-09-14 11:03:21 +0100 |
commit | fbc71ee712635ed64c50ca694735a84ec794eb11 (patch) | |
tree | bf1dd7335306b7f320262d45d0d5b6d02f5a0b27 /core | |
parent | a971d409cb1063a2089d936abf3d3ab70bbbabb6 (diff) | |
download | sttp-fbc71ee712635ed64c50ca694735a84ec794eb11.tar.gz sttp-fbc71ee712635ed64c50ca694735a84ec794eb11.tar.bz2 sttp-fbc71ee712635ed64c50ca694735a84ec794eb11.zip |
Renaming "handler" to "backend"
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/scala/com/softwaremill/sttp/FollowRedirectsBackend.scala (renamed from core/src/main/scala/com/softwaremill/sttp/FollowRedirectsHandler.scala) | 8 | ||||
-rw-r--r-- | core/src/main/scala/com/softwaremill/sttp/HttpURLConnectionBackend.scala (renamed from core/src/main/scala/com/softwaremill/sttp/HttpURLConnectionHandler.scala) | 16 | ||||
-rw-r--r-- | core/src/main/scala/com/softwaremill/sttp/RequestT.scala | 6 | ||||
-rw-r--r-- | core/src/main/scala/com/softwaremill/sttp/SttpBackend.scala (renamed from core/src/main/scala/com/softwaremill/sttp/SttpHandler.scala) | 12 | ||||
-rw-r--r-- | core/src/main/scala/com/softwaremill/sttp/package.scala | 2 |
5 files changed, 22 insertions, 22 deletions
diff --git a/core/src/main/scala/com/softwaremill/sttp/FollowRedirectsHandler.scala b/core/src/main/scala/com/softwaremill/sttp/FollowRedirectsBackend.scala index 6fe9ce9..accd6b5 100644 --- a/core/src/main/scala/com/softwaremill/sttp/FollowRedirectsHandler.scala +++ b/core/src/main/scala/com/softwaremill/sttp/FollowRedirectsBackend.scala @@ -3,8 +3,8 @@ package com.softwaremill.sttp import java.net.URI import scala.language.higherKinds -class FollowRedirectsHandler[R[_], S](delegate: SttpHandler[R, S]) - extends SttpHandler[R, S] { +class FollowRedirectsBackend[R[_], S](delegate: SttpBackend[R, S]) + extends SttpBackend[R, S] { def send[T](request: Request[T, S]): R[Response[T]] = { sendWithCounter(request, 0) @@ -31,7 +31,7 @@ class FollowRedirectsHandler[R[_], S](delegate: SttpHandler[R, S]) redirects: Int): R[Response[T]] = { response.header(LocationHeader).fold(responseMonad.unit(response)) { loc => - if (redirects >= FollowRedirectsHandler.MaxRedirects) { + if (redirects >= FollowRedirectsBackend.MaxRedirects) { responseMonad.unit(Response(Left("Too many redirects"), 0, Nil, Nil)) } else { followRedirect(request, response, redirects, loc) @@ -68,6 +68,6 @@ class FollowRedirectsHandler[R[_], S](delegate: SttpHandler[R, S]) override def responseMonad: MonadError[R] = delegate.responseMonad } -object FollowRedirectsHandler { +object FollowRedirectsBackend { private[sttp] val MaxRedirects = 32 } diff --git a/core/src/main/scala/com/softwaremill/sttp/HttpURLConnectionHandler.scala b/core/src/main/scala/com/softwaremill/sttp/HttpURLConnectionBackend.scala index c482e6d..2dbb13d 100644 --- a/core/src/main/scala/com/softwaremill/sttp/HttpURLConnectionHandler.scala +++ b/core/src/main/scala/com/softwaremill/sttp/HttpURLConnectionBackend.scala @@ -13,8 +13,8 @@ import scala.io.Source import scala.collection.JavaConverters._ import scala.concurrent.duration.{Duration, FiniteDuration} -class HttpURLConnectionHandler private (connectionTimeout: FiniteDuration) - extends SttpHandler[Id, Nothing] { +class HttpURLConnectionBackend private (connectionTimeout: FiniteDuration) + extends SttpBackend[Id, Nothing] { override def send[T](r: Request[T, Nothing]): Response[T] = { val c = new URL(r.uri.toString).openConnection().asInstanceOf[HttpURLConnection] @@ -24,7 +24,7 @@ class HttpURLConnectionHandler private (connectionTimeout: FiniteDuration) c.setReadTimeout(timeout(r.options.readTimeout)) c.setConnectTimeout(timeout(connectionTimeout)) - // redirects are handled in SttpHandler + // redirects are handled by FollowRedirectsBackend c.setInstanceFollowRedirects(false) if (r.body != NoBody) { @@ -256,11 +256,11 @@ class HttpURLConnectionHandler private (connectionTimeout: FiniteDuration) override def close(): Unit = {} } -object HttpURLConnectionHandler { +object HttpURLConnectionBackend { def apply( - connectionTimeout: FiniteDuration = SttpHandler.DefaultConnectionTimeout) - : SttpHandler[Id, Nothing] = - new FollowRedirectsHandler[Id, Nothing]( - new HttpURLConnectionHandler(connectionTimeout)) + connectionTimeout: FiniteDuration = SttpBackend.DefaultConnectionTimeout) + : SttpBackend[Id, Nothing] = + new FollowRedirectsBackend[Id, Nothing]( + new HttpURLConnectionBackend(connectionTimeout)) } diff --git a/core/src/main/scala/com/softwaremill/sttp/RequestT.scala b/core/src/main/scala/com/softwaremill/sttp/RequestT.scala index 6e76f6f..320efef 100644 --- a/core/src/main/scala/com/softwaremill/sttp/RequestT.scala +++ b/core/src/main/scala/com/softwaremill/sttp/RequestT.scala @@ -16,7 +16,7 @@ import scala.language.higherKinds * client code to consume it. An exception to this are * streaming responses, which need to fully consumed by the * client if such a response type is requested. - * @param tags Request-specific tags which can be used by handlers for + * @param tags Request-specific tags which can be used by backends for * logging, metrics, etc. Not used by default. * @tparam U Specifies if the method & uri are specified. By default can be * either: @@ -233,13 +233,13 @@ case class RequestT[U[_], T, +S]( def tag(k: String): Option[Any] = tags.get(k) - def send[R[_]]()(implicit handler: SttpHandler[R, S], + def send[R[_]]()(implicit backend: SttpBackend[R, S], isIdInRequest: IsIdInRequest[U]): R[Response[T]] = { // we could avoid the asInstanceOf by creating an artificial copy // changing the method & url fields using `isIdInRequest`, but that // would be only to satisfy the type checker, and a needless copy at // runtime. - handler.send(this.asInstanceOf[RequestT[Id, T, S]]) + backend.send(this.asInstanceOf[RequestT[Id, T, S]]) } private def hasContentType: Boolean = diff --git a/core/src/main/scala/com/softwaremill/sttp/SttpHandler.scala b/core/src/main/scala/com/softwaremill/sttp/SttpBackend.scala index cb03567..6eb312f 100644 --- a/core/src/main/scala/com/softwaremill/sttp/SttpHandler.scala +++ b/core/src/main/scala/com/softwaremill/sttp/SttpBackend.scala @@ -5,22 +5,22 @@ import scala.concurrent.duration._ /** * @tparam R The type constructor in which responses are wrapped. E.g. `Id` - * for synchronous handlers, `Future` for asynchronous handlers. - * @tparam S The type of streams that are supported by the handler. `Nothing`, - * if streaming requests/responses is not supported by this handler. + * for synchronous backends, `Future` for asynchronous backends. + * @tparam S The type of streams that are supported by the backend. `Nothing`, + * if streaming requests/responses is not supported by this backend. */ -trait SttpHandler[R[_], -S] { +trait SttpBackend[R[_], -S] { def send[T](request: Request[T, S]): R[Response[T]] def close(): Unit /** * The monad in which the responses are wrapped. Allows writing wrapper - * handlers, which map/flatMap over the return value of [[send]]. + * backends, which map/flatMap over the return value of [[send]]. */ def responseMonad: MonadError[R] } -object SttpHandler { +object SttpBackend { private[sttp] val DefaultConnectionTimeout = 30.seconds } diff --git a/core/src/main/scala/com/softwaremill/sttp/package.scala b/core/src/main/scala/com/softwaremill/sttp/package.scala index a9950be..c1178d9 100644 --- a/core/src/main/scala/com/softwaremill/sttp/package.scala +++ b/core/src/main/scala/com/softwaremill/sttp/package.scala @@ -23,7 +23,7 @@ package object sttp { /** * Provide an implicit value of this type to serialize arbitrary classes into a request body. - * Handlers might also provide special logic for serializer instances which they define (e.g. to handle streaming). + * Backends might also provide special logic for serializer instances which they define (e.g. to handle streaming). */ type BodySerializer[B] = B => BasicRequestBody |