aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoradamw <adam@warski.org>2017-08-02 12:08:32 +0200
committeradamw <adam@warski.org>2017-08-02 12:08:32 +0200
commit02be9a13bf6e4a6da8a5ced85ae6b716a64c919a (patch)
tree70fe587146ab77214c47444809af9cf4564728b6
parent284860a8506589b19ca1afd2a33cecb45747f340 (diff)
downloadsttp-02be9a13bf6e4a6da8a5ced85ae6b716a64c919a.tar.gz
sttp-02be9a13bf6e4a6da8a5ced85ae6b716a64c919a.tar.bz2
sttp-02be9a13bf6e4a6da8a5ced85ae6b716a64c919a.zip
OkHttp docs
-rw-r--r--README.md14
-rw-r--r--core/src/main/scala/com/softwaremill/sttp/UriInterpolator.scala24
2 files changed, 29 insertions, 9 deletions
diff --git a/README.md b/README.md
index 5e091f4..0d0065d 100644
--- a/README.md
+++ b/README.md
@@ -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 =>