diff options
-rw-r--r-- | README.md | 14 | ||||
-rw-r--r-- | core/src/main/scala/com/softwaremill/sttp/UriInterpolator.scala | 24 |
2 files changed, 29 insertions, 9 deletions
@@ -184,6 +184,8 @@ uri"$scheme://$subdomains.example.com?x=$vx&$params#$jumpTo" | `FutureAsyncHttpClientHandler` | `scala.concurrent.Future` | - | | `ScalazAsyncHttpClientHandler` | `scalaz.concurrent.Task` | - | | `MonixAsyncHttpClientHandler` | `monix.eval.Task` | `monix.reactive.Observable[ByteBuffer]` | +| `OkHttpSyncClientHandler` | None (`Id`) | - | +| `OkHttpFutureClientHandler` | `scala.concurrent.Future` | - | ### `HttpURLConnectionSttpHandler` @@ -336,6 +338,18 @@ val response: Task[Response[Observable[ByteBuffer]]] = .send() ``` +### `OkHttpClientHandler` + +To use, add the following dependency to your project: + +```scala +"com.softwaremill.sttp" %% "okhttp-client-handler" % "0.0.3" +``` + +This handler depends on [OkHttp](http://square.github.io/okhttp/), and offers +both a **synchronous** (`OkHttpSyncClientHandler`) and **asynchronous** +(`OkHttpFutureClientHandler`), `Future`-based handlers. + ## Request type All request descriptions have type `RequestT[U, T, S]` (T as in Template). diff --git a/core/src/main/scala/com/softwaremill/sttp/UriInterpolator.scala b/core/src/main/scala/com/softwaremill/sttp/UriInterpolator.scala index 0472828..a99bab8 100644 --- a/core/src/main/scala/com/softwaremill/sttp/UriInterpolator.scala +++ b/core/src/main/scala/com/softwaremill/sttp/UriInterpolator.scala @@ -49,9 +49,11 @@ object UriInterpolator { // way it's possible to extend existing URIs. Without special-casing // the embedded URI would be escaped and become part of the host // as a whole. - if (tokens == Vector(StringToken("")) && nextExpression.toString.contains("://")) { + if (tokens == Vector(StringToken("")) && nextExpression.toString.contains( + "://")) { def tokenizeExpressionAsString(): Unit = { - val (nextTokenizer, nextTokens) = tokenizer.tokenize(nextExpression.toString) + val (nextTokenizer, nextTokens) = + tokenizer.tokenize(nextExpression.toString) tokenizer = nextTokenizer tokens = tokens ++ nextTokens } @@ -336,7 +338,11 @@ object UriInterpolator { import com.softwaremill.sttp.Uri.{QueryFragment => QF} override def fromTokens(u: Uri, t: Vector[Token]): (Uri, Vector[Token]) = - fromStartingToken(u, t, QueryStart, Set[Token](FragmentStart), queryFromTokens) + fromStartingToken(u, + t, + QueryStart, + Set[Token](FragmentStart), + queryFromTokens) private def queryFromTokens(u: Uri, tokens: Vector[Token]): Uri = { val qfs = @@ -398,12 +404,12 @@ object UriInterpolator { * The component is terminated by any of `nextComponentTokens`. */ private def fromStartingToken( - u: Uri, - t: Vector[Token], - startingToken: Token, - nextComponentTokens: Set[Token], - componentFromTokens: (Uri, Vector[Token]) => Uri) - : (Uri, Vector[Token]) = { + u: Uri, + t: Vector[Token], + startingToken: Token, + nextComponentTokens: Set[Token], + componentFromTokens: (Uri, Vector[Token]) => Uri) + : (Uri, Vector[Token]) = { t match { case `startingToken` +: tt => |