From 4f0dd23f3f1f8e7db67d670b3736c403b294bb42 Mon Sep 17 00:00:00 2001 From: adamw Date: Mon, 17 Oct 2022 16:00:57 +0200 Subject: [PATCH] Release 3.8.3 --- README.md | 8 +- generated-docs/out/backends/akka.md | 2 +- generated-docs/out/backends/catseffect.md | 90 +++------------ generated-docs/out/backends/finagle.md | 2 +- generated-docs/out/backends/fs2.md | 104 +++--------------- generated-docs/out/backends/future.md | 61 +--------- generated-docs/out/backends/http4s.md | 4 +- .../out/backends/javascript/fetch.md | 12 +- generated-docs/out/backends/monix.md | 67 +++-------- generated-docs/out/backends/native/curl.md | 2 +- generated-docs/out/backends/scalaz.md | 39 +------ generated-docs/out/backends/summary.md | 21 +++- generated-docs/out/backends/synchronous.md | 6 +- .../out/backends/wrappers/custom.md | 13 ++- .../out/backends/wrappers/logging.md | 4 +- .../out/backends/wrappers/opentelemetry.md | 6 +- .../out/backends/wrappers/prometheus.md | 2 +- generated-docs/out/backends/zio.md | 55 ++------- generated-docs/out/conf/ssl.md | 48 ++++---- generated-docs/out/examples.md | 53 +++++---- generated-docs/out/index.md | 2 +- generated-docs/out/json.md | 24 ++-- generated-docs/out/openapi.md | 8 +- generated-docs/out/quickstart.md | 6 +- generated-docs/out/resilience.md | 2 +- generated-docs/out/simple_sync.md | 4 +- generated-docs/out/testing.md | 2 +- generated-docs/out/websockets.md | 24 ++-- 28 files changed, 200 insertions(+), 471 deletions(-) diff --git a/README.md b/README.md index 269330e0dc..9986f7ff64 100755 --- a/README.md +++ b/README.md @@ -45,14 +45,14 @@ sttp (v2) documentation is available at [sttp.softwaremill.com/en/v2](http://stt sttp (v1) documentation is available at [sttp.softwaremill.com/en/v1](https://sttp.softwaremill.com/en/v1). -scaladoc is available at [https://www.javadoc.io](https://www.javadoc.io/doc/com.softwaremill.sttp.client3/core_2.12/3.8.2) +scaladoc is available at [https://www.javadoc.io](https://www.javadoc.io/doc/com.softwaremill.sttp.client3/core_2.12/3.8.3) ## Quickstart with Ammonite If you are an [Ammonite](http://ammonite.io) user, you can quickly start experimenting with sttp by copy-pasting the following: ```scala -import $ivy.`com.softwaremill.sttp.client3::core:3.8.2` +import $ivy.`com.softwaremill.sttp.client3::core:3.8.3` import sttp.client3.quick._ quickRequest.get(uri"http://httpbin.org/ip").send(backend) ``` @@ -64,7 +64,7 @@ This brings in the sttp API and a synchronous backend instance. Add the following dependency: ```scala -"com.softwaremill.sttp.client3" %% "core" % "3.8.2" +"com.softwaremill.sttp.client3" %% "core" % "3.8.3" ``` Then, import: @@ -102,7 +102,7 @@ The documentation is typechecked using [mdoc](https://scalameta.org/mdoc/). The When generating documentation, it's best to set the version to the current one, so that the generated doc files don't include modifications with the current snapshot version. -That is, in sbt run: `set version := "3.8.2"`, before running `mdoc` in `docs`. +That is, in sbt run: `set version := "3.8.3"`, before running `mdoc` in `docs`. ### Testing the Scala.JS backend diff --git a/generated-docs/out/backends/akka.md b/generated-docs/out/backends/akka.md index 2e60aa6af2..ff05e0bd13 100644 --- a/generated-docs/out/backends/akka.md +++ b/generated-docs/out/backends/akka.md @@ -3,7 +3,7 @@ This backend is based on [akka-http](http://doc.akka.io/docs/akka-http/current/scala/http/). To use, add the following dependency to your project: ``` -"com.softwaremill.sttp.client3" %% "akka-http-backend" % "3.8.2" +"com.softwaremill.sttp.client3" %% "akka-http-backend" % "3.8.3" ``` A fully **asynchronous** backend. Uses the `Future` effect to return responses. There are also [other `Future`-based backends](future.md), which don't depend on Akka. diff --git a/generated-docs/out/backends/catseffect.md b/generated-docs/out/backends/catseffect.md index 8d51d9950b..b4b1e79642 100644 --- a/generated-docs/out/backends/catseffect.md +++ b/generated-docs/out/backends/catseffect.md @@ -1,103 +1,49 @@ # cats-effect backend -The [Cats Effect](https://github.com/typelevel/cats-effect) backend is **asynchronous**. It can be created for any type implementing the `cats.effect.Concurrent` typeclass, such as `cats.effect.IO`. Sending a request is a non-blocking, lazily-evaluated operation and results in a wrapped response. There's a transitive dependency on `cats-effect`. +The [Cats Effect](https://github.com/typelevel/cats-effect) backend is **asynchronous**. +It can be created for any type implementing the `cats.effect.Concurrent` typeclass, such as `cats.effect.IO`. +Sending a request is a non-blocking, lazily-evaluated operation and results in a wrapped response. +There's a transitive dependency on `cats-effect`. Note that all [fs2](fs2.md) backends also support any cats-effect effect, additionally supporting request & response streaming. -## Using async-http-client +Also note that the [http4s](http4s.md) backend can also be created for a type implementing the cats-effect’s `Async` typeclass, and supports streaming as in [fs2](fs2.md). -To use, add the following dependency to your project: -```scala -"com.softwaremill.sttp.client3" %% "async-http-client-backend-cats" % "3.8.2" // for cats-effect 3.x -// or -"com.softwaremill.sttp.client3" %% "async-http-client-backend-cats-ce2" % "3.8.2" // for cats-effect 2.x -``` - -This backend depends on [async-http-client](https://github.com/AsyncHttpClient/async-http-client), uses [Netty](http://netty.io) behind the scenes. - -Alternatively, the [http4s](http4s.md) backend can also be created for a type implementing the cats-effect's `Async` typeclass, and supports streaming as in [fs2](fs2.md). +## Using Armeria -Next you'll need to define a backend instance. This can be done in two basic ways: +Creation of the backend can be done in two basic ways: * by creating an effect, which describes how the backend is created, or instantiating the backend directly. In this case, you'll need to close the backend manually -* by creating a `Resource`, which will instantiate the backend and close it after it has been used +* by creating a `Resource`, which will instantiate the backend and close it after it has been used. -A non-comprehensive summary of how the backend can be created is as follows: +Firstly, add the following dependency to your project: ```scala -import cats.effect.IO -import sttp.client3.asynchttpclient.cats.AsyncHttpClientCatsBackend - -// the type class instance needs to be provided explicitly (e.g. `cats.effect.IO`). -// the effect type must implement the Async typeclass -AsyncHttpClientCatsBackend[IO]().flatMap { backend => ??? } +"com.softwaremill.sttp.client3" %% "armeria-backend-cats" % "3.8.3" // for cats-effect 3.x +// or +"com.softwaremill.sttp.client3" %% "armeria-backend-cats-ce2" % "3.8.3" // for cats-effect 2.x ``` -or, if you'd like to use a custom configuration: +create client: ```scala import cats.effect.IO -import org.asynchttpclient.AsyncHttpClientConfig -import sttp.client3.asynchttpclient.cats.AsyncHttpClientCatsBackend - -val config: AsyncHttpClientConfig = ??? -AsyncHttpClientCatsBackend.usingConfig[IO](config).flatMap { backend => ??? } -``` - -or, if you'd like to use adjust the configuration sttp creates: +import sttp.client3.armeria.cats.ArmeriaCatsBackend -```scala -import cats.effect.IO -import org.asynchttpclient.DefaultAsyncHttpClientConfig -import sttp.client3.SttpBackendOptions -import sttp.client3.asynchttpclient.cats.AsyncHttpClientCatsBackend +val backend = ArmeriaCatsBackend[IO]() -val sttpOptions: SttpBackendOptions = SttpBackendOptions.Default -val adjustFunction: DefaultAsyncHttpClientConfig.Builder => DefaultAsyncHttpClientConfig.Builder = ??? -AsyncHttpClientCatsBackend.usingConfigBuilder[IO](adjustFunction, sttpOptions).flatMap { backend => ??? } +// You can use the default client which reuses the connection pool of ClientFactory.ofDefault() +ArmeriaCatsBackend.usingDefaultClient[IO]() ``` or, if you'd like the backend to be wrapped in cats-effect `Resource`: -```scala -import cats.effect.IO -import sttp.client3.asynchttpclient.cats.AsyncHttpClientCatsBackend - -AsyncHttpClientCatsBackend.resource[IO]().use { backend => ??? } -``` - -or, if you'd like to instantiate the `AsyncHttpClient` yourself: - -```scala -import cats.effect.IO -import org.asynchttpclient.AsyncHttpClient -import sttp.client3.asynchttpclient.cats.AsyncHttpClientCatsBackend - -val asyncHttpClient: AsyncHttpClient = ??? -val backend = AsyncHttpClientCatsBackend.usingClient[IO](asyncHttpClient) -``` - -## Using Armeria - -To use, add the following dependency to your project: - -```scala -"com.softwaremill.sttp.client3" %% "armeria-backend-cats" % "3.8.2" // for cats-effect 3.x -// or -"com.softwaremill.sttp.client3" %% "armeria-backend-cats-ce2" % "3.8.2" // for cats-effect 2.x -``` - -create client: - ```scala import cats.effect.IO import sttp.client3.armeria.cats.ArmeriaCatsBackend -val backend = ArmeriaCatsBackend[IO]() - -// You can use the default client which reuses the connection pool of ClientFactory.ofDefault() -ArmeriaCatsBackend.usingDefaultClient[IO]() +ArmeriaCatsBackend.resource[IO]().use { backend => ??? } ``` or, if you'd like to instantiate the [WebClient](https://armeria.dev/docs/client-http) yourself: diff --git a/generated-docs/out/backends/finagle.md b/generated-docs/out/backends/finagle.md index 3a3ac72a7d..28b3e309f1 100644 --- a/generated-docs/out/backends/finagle.md +++ b/generated-docs/out/backends/finagle.md @@ -3,7 +3,7 @@ To use, add the following dependency to your project: ``` -"com.softwaremill.sttp.client3" %% "finagle-backend" % "3.8.2" +"com.softwaremill.sttp.client3" %% "finagle-backend" % "3.8.3" ``` Next you'll need to add an implicit value: diff --git a/generated-docs/out/backends/fs2.md b/generated-docs/out/backends/fs2.md index 3e423de4cf..ccb3549488 100644 --- a/generated-docs/out/backends/fs2.md +++ b/generated-docs/out/backends/fs2.md @@ -4,12 +4,17 @@ The [fs2](https://github.com/functional-streams-for-scala/fs2) backends are **as ## Using HttpClient -To use, add the following dependency to your project: +Creation of the backend can be done in two basic ways: + +* by creating a `Resource`, which will instantiate the backend and close it after it has been used. +* by creating an effect, which describes how a backend is created, or instantiating the backend directly. In this case, you'll need to close the backend manually, as well as provide a `Dispatcher` instance + +Firstly, add the following dependency to your project: ```scala -"com.softwaremill.sttp.client3" %% "fs2" % "3.8.2" // for cats-effect 3.x & fs2 3.x +"com.softwaremill.sttp.client3" %% "fs2" % "3.8.3" // for cats-effect 3.x & fs2 3.x // or -"com.softwaremill.sttp.client3" %% "fs2-ce2" % "3.8.2" // for cats-effect 2.x & fs2 2.x +"com.softwaremill.sttp.client3" %% "fs2-ce2" % "3.8.3" // for cats-effect 2.x & fs2 2.x ``` Obtain a cats-effect `Resource` which creates the backend, and closes the thread pool after the resource is no longer used: @@ -55,95 +60,15 @@ Host header override is supported in environments running Java 12 onwards, but i -Djdk.httpclient.allowRestrictedHeaders=host ``` -## Using async-http-client - -To use, add the following dependency to your project: - -```scala -"com.softwaremill.sttp.client3" %% "async-http-client-backend-fs2" % "3.8.2" // for cats-effect 3.x & fs2 3.x -// or -"com.softwaremill.sttp.client3" %% "async-http-client-backend-fs2-ce2" % "3.8.2" // for cats-effect 2.x & fs2 2.x -``` - -This backend depends on [async-http-client](https://github.com/AsyncHttpClient/async-http-client) and uses [Netty](http://netty.io) behind the scenes. - -Next you'll need to define a backend instance as an implicit value. This can be done in two basic ways: - -* by creating a `Resource`, which will instantiate the backend (along with a `Dispatcher`) and close it after it has been used -* by creating an effect, which describes how a backend is created, or instantiating the backend directly. In this case, you'll need to close the backend manually, as well as provide a `Dispatcher` instance - -Below you can find a non-comprehensive summary of how the backend can be created. The easiest form is to use a cats-effect `Resource`: - -```scala -import cats.effect.IO -import sttp.client3.asynchttpclient.fs2.AsyncHttpClientFs2Backend - -AsyncHttpClientFs2Backend.resource[IO]().use { backend => ??? } -``` - -or, by providing a custom dispatcher: - -```scala -import cats.effect.IO -import cats.effect.std.Dispatcher -import sttp.client3.asynchttpclient.fs2.AsyncHttpClientFs2Backend - -val dispatcher: Dispatcher[IO] = ??? - -AsyncHttpClientFs2Backend[IO](dispatcher).flatMap { backend => ??? } -``` - -or, if you'd like to use a custom configuration: - -```scala -import cats.effect.IO -import cats.effect.std.Dispatcher -import org.asynchttpclient.AsyncHttpClientConfig -import sttp.client3.asynchttpclient.fs2.AsyncHttpClientFs2Backend - -val dispatcher: Dispatcher[IO] = ??? - -val config: AsyncHttpClientConfig = ??? -AsyncHttpClientFs2Backend.usingConfig[IO](config, dispatcher).flatMap { backend => ??? } -``` - -or, if you'd like to use adjust the configuration sttp creates: - -```scala -import cats.effect.IO -import cats.effect.std.Dispatcher -import org.asynchttpclient.DefaultAsyncHttpClientConfig -import sttp.client3.SttpBackendOptions -import sttp.client3.asynchttpclient.fs2.AsyncHttpClientFs2Backend - -val sttpOptions: SttpBackendOptions = SttpBackendOptions.Default -val adjustFunction: DefaultAsyncHttpClientConfig.Builder => DefaultAsyncHttpClientConfig.Builder = ??? -val dispatcher: Dispatcher[IO] = ??? - -AsyncHttpClientFs2Backend.usingConfigBuilder[IO](dispatcher, adjustFunction, sttpOptions).flatMap { backend => ??? } -``` - -or, if you'd like to instantiate the AsyncHttpClient yourself: - -```scala -import cats.effect.IO -import cats.effect.std.Dispatcher -import org.asynchttpclient.AsyncHttpClient -import sttp.client3.asynchttpclient.fs2.AsyncHttpClientFs2Backend - -val dispatcher: Dispatcher[IO] = ??? -val asyncHttpClient: AsyncHttpClient = ??? -val backend = AsyncHttpClientFs2Backend.usingClient[IO](asyncHttpClient, dispatcher) -``` ## Using Armeria To use, add the following dependency to your project: ```scala -"com.softwaremill.sttp.client3" %% "armeria-backend-fs2" % "3.8.2" // for cats-effect 3.x & fs2 3.x +"com.softwaremill.sttp.client3" %% "armeria-backend-fs2" % "3.8.3" // for cats-effect 3.x & fs2 3.x // or -"com.softwaremill.sttp.client3" %% "armeria-backend-fs2" % "3.8.2" // for cats-effect 2.x & fs2 2.x +"com.softwaremill.sttp.client3" %% "armeria-backend-fs2" % "3.8.3" // for cats-effect 2.x & fs2 2.x ``` create client: @@ -200,10 +125,9 @@ import cats.effect.IO import fs2.Stream import sttp.capabilities.fs2.Fs2Streams import sttp.client3._ -import sttp.client3.armeria.fs2.ArmeriaFs2Backend -import sttp.client3.asynchttpclient.fs2.AsyncHttpClientFs2Backend +import sttp.client3.httpclient.fs2.HttpClientFs2Backend -val effect = AsyncHttpClientFs2Backend.resource[IO]().use { backend => +val effect = HttpClientFs2Backend.resource[IO]().use { backend => val stream: Stream[IO, Byte] = ??? basicRequest @@ -220,10 +144,10 @@ import cats.effect.IO import fs2.Stream import sttp.capabilities.fs2.Fs2Streams import sttp.client3._ -import sttp.client3.asynchttpclient.fs2.AsyncHttpClientFs2Backend +import sttp.client3.httpclient.fs2.HttpClientFs2Backend import scala.concurrent.duration.Duration -val effect = AsyncHttpClientFs2Backend.resource[IO]().use { backend => +val effect = HttpClientFs2Backend.resource[IO]().use { backend => val response: IO[Response[Either[String, Stream[IO, Byte]]]] = basicRequest .post(uri"...") diff --git a/generated-docs/out/backends/future.md b/generated-docs/out/backends/future.md index 3d3deea646..ed88c93468 100644 --- a/generated-docs/out/backends/future.md +++ b/generated-docs/out/backends/future.md @@ -10,7 +10,6 @@ Class Supported stream type ===================================== ================================================ ========================== ``HttpClientFutureBackend`` n/a yes (regular) ``AkkaHttpBackend`` ``akka.stream.scaladsl.Source[ByteString, Any]`` yes (regular & streaming) -``AsyncHttpClientFutureBackend`` n/a no ``OkHttpFutureBackend`` n/a yes (regular) ``ArmeriaFutureBackend`` n/a n/a ===================================== ================================================ ========================== @@ -21,7 +20,7 @@ Class Supported stream type To use, you don't need any extra dependencies, `core` is enough: ``` -"com.softwaremill.sttp.client3" %% "core" % "3.8.2" +"com.softwaremill.sttp.client3" %% "core" % "3.8.3" ``` You'll need the following imports: @@ -54,63 +53,13 @@ Host header override is supported in environments running Java 12 onwards, but i -Djdk.httpclient.allowRestrictedHeaders=host ``` -## Using async-http-client - -To use, add the following dependency to your project: - -```scala -"com.softwaremill.sttp.client3" %% "async-http-client-backend-future" % "3.8.2" -``` - -And some imports: - -```scala -import sttp.client3._ -import sttp.client3.asynchttpclient.future.AsyncHttpClientFutureBackend -``` - -This backend depends on [async-http-client](https://github.com/AsyncHttpClient/async-http-client) and uses [Netty](http://netty.io) behind the scenes. - -Next you'll need to create the backend instance: - -```scala -val backend = AsyncHttpClientFutureBackend() -``` - -or, if you'd like to use custom configuration: - -```scala -import org.asynchttpclient.AsyncHttpClientConfig - -val config: AsyncHttpClientConfig = ??? -val backend = AsyncHttpClientFutureBackend.usingConfig(config) -``` - -or, if you'd like to use adjust the configuration sttp creates: - -```scala -import org.asynchttpclient.DefaultAsyncHttpClientConfig - -val sttpOptions: SttpBackendOptions = SttpBackendOptions.Default -val adjustFunction: DefaultAsyncHttpClientConfig.Builder => DefaultAsyncHttpClientConfig.Builder = ??? -val backend = AsyncHttpClientFutureBackend.usingConfigBuilder(adjustFunction, sttpOptions) -``` - -or, if you'd like to instantiate the AsyncHttpClient yourself: - -```scala -import org.asynchttpclient.AsyncHttpClient - -val asyncHttpClient: AsyncHttpClient = ??? -val backend = AsyncHttpClientFutureBackend.usingClient(asyncHttpClient) -``` ## Using OkHttp To use, add the following dependency to your project: ```scala -"com.softwaremill.sttp.client3" %% "okhttp-backend" % "3.8.2" +"com.softwaremill.sttp.client3" %% "okhttp-backend" % "3.8.3" ``` and some imports: @@ -131,8 +80,8 @@ or, if you'd like to instantiate the OkHttpClient yourself: ```scala import okhttp3.OkHttpClient -val asyncHttpClient: OkHttpClient = ??? -val backend = OkHttpFutureBackend.usingClient(asyncHttpClient) +val okHttpClient: OkHttpClient = ??? +val backend = OkHttpFutureBackend.usingClient(okHttpClient) ``` This backend depends on [OkHttp](http://square.github.io/okhttp/) and fully supports HTTP/2. @@ -142,7 +91,7 @@ This backend depends on [OkHttp](http://square.github.io/okhttp/) and fully supp To use, add the following dependency to your project: ``` -"com.softwaremill.sttp.client3" %% "armeria-backend" % "3.8.2" +"com.softwaremill.sttp.client3" %% "armeria-backend" % "3.8.3" ``` add imports: diff --git a/generated-docs/out/backends/http4s.md b/generated-docs/out/backends/http4s.md index 154a9aaf1e..5b22ffb91b 100644 --- a/generated-docs/out/backends/http4s.md +++ b/generated-docs/out/backends/http4s.md @@ -3,9 +3,9 @@ This backend is based on [http4s](https://http4s.org) (client) and is **asynchronous**. To use, add the following dependency to your project: ```scala -"com.softwaremill.sttp.client3" %% "http4s-backend" % "3.8.2" // for cats-effect 3.x & http4s 1.0.0-Mx +"com.softwaremill.sttp.client3" %% "http4s-backend" % "3.8.3" // for cats-effect 3.x & http4s 1.0.0-Mx // or -"com.softwaremill.sttp.client3" %% "http4s-ce2-backend" % "3.8.2" // for cats-effect 2.x & http4s 0.21.x +"com.softwaremill.sttp.client3" %% "http4s-ce2-backend" % "3.8.3" // for cats-effect 2.x & http4s 0.21.x ``` The backend can be created in a couple of ways, e.g.: diff --git a/generated-docs/out/backends/javascript/fetch.md b/generated-docs/out/backends/javascript/fetch.md index 51378761bb..3eaaea9df5 100644 --- a/generated-docs/out/backends/javascript/fetch.md +++ b/generated-docs/out/backends/javascript/fetch.md @@ -7,7 +7,7 @@ A JavaScript backend with web socket support. Implemented using the [Fetch API]( This is the default backend, available in the main jar for JS. To use, add the following dependency to your project: ``` -"com.softwaremill.sttp.client3" %%% "core" % "3.8.2" +"com.softwaremill.sttp.client3" %%% "core" % "3.8.3" ``` And create the backend instance: @@ -26,7 +26,7 @@ Note that `Fetch` does not pass cookies by default. If your request needs cookie To use, add the following dependency to your project: ``` -"com.softwaremill.sttp.client3" %%% "monix" % "3.8.2" +"com.softwaremill.sttp.client3" %%% "monix" % "3.8.3" ``` And create the backend instance: @@ -40,7 +40,7 @@ val backend = FetchMonixBackend() To use, add the following dependency to your project: ``` -"com.softwaremill.sttp.client3" %%% "zio" % "3.8.2" +"com.softwaremill.sttp.client3" %%% "zio" % "3.8.3" ``` And create the backend instance: @@ -55,13 +55,13 @@ Any effect implementing the cats-effect `Concurrent` typeclass can be used. To u your project: ``` -"com.softwaremill.sttp.client3" %%% "cats" % "3.8.2" +"com.softwaremill.sttp.client3" %%% "cats" % "3.8.3" ``` If you are on Cats Effect 2 (CE2) you will need to add the CE2 specific dependency instead: ``` -"com.softwaremill.sttp.client3" %%% "catsce2 % "3.8.2" +"com.softwaremill.sttp.client3" %%% "catsce2 % "3.8.3" ``` And create the backend instance: @@ -129,7 +129,7 @@ Streaming support is provided via `FetchMonixBackend`. Note that streaming suppo To use, add the following dependency to your project: ``` -"com.softwaremill.sttp.client3" %%% "monix" % "3.8.2" +"com.softwaremill.sttp.client3" %%% "monix" % "3.8.3" ``` An example of streaming a response: diff --git a/generated-docs/out/backends/monix.md b/generated-docs/out/backends/monix.md index b39784950e..cdedd02c80 100644 --- a/generated-docs/out/backends/monix.md +++ b/generated-docs/out/backends/monix.md @@ -4,13 +4,18 @@ There are several backend implementations which are `monix.eval.Task`-based. The ## Using HttpClient -To use, add the following dependency to your project: +Creation of the backend can be done in two basic ways: + +* by creating a `Task`, which describes how the backend is created, or instantiating the backend directly. In this case, you'll need to close the backend manually. +* by creating a `Resource`, which will instantiate the backend and close it after it has been used. + +Firstly, add the following dependency to your project: ``` -"com.softwaremill.sttp.client3" %% "monix" % "3.8.2" +"com.softwaremill.sttp.client3" %% "monix" % "3.8.3" ``` -Create the backend using: +and create the backend using: ```scala import sttp.client3.httpclient.monix.HttpClientMonixBackend @@ -34,55 +39,13 @@ Host header override is supported in environments running Java 12 onwards, but i -Djdk.httpclient.allowRestrictedHeaders=host ``` -## Using async-http-client - -To use, add the following dependency to your project: - -```scala -"com.softwaremill.sttp.client3" %% "async-http-client-backend-monix" % "3.8.2" -``` - -This backend depends on [async-http-client](https://github.com/AsyncHttpClient/async-http-client), uses [Netty](http://netty.io) behind the scenes. - -Next you'll need to define a backend instance as an implicit value. This can be done in two basic ways: - -* by creating a `Task`, which describes how the backend is created, or instantiating the backend directly. In this case, you'll need to close the backend manually -* by creating a `Resource`, which will instantiate the backend and close it after it has been used - -A non-comprehensive summary of how the backend can be created is as follows: - -```scala -import sttp.client3.asynchttpclient.monix.AsyncHttpClientMonixBackend -import sttp.client3._ - -AsyncHttpClientMonixBackend().flatMap { backend => ??? } - -// or, if you'd like the backend to be wrapped in cats-effect Resource: -AsyncHttpClientMonixBackend.resource().use { backend => ??? } - -// or, if you'd like to use custom configuration: -import org.asynchttpclient.AsyncHttpClientConfig -val config: AsyncHttpClientConfig = ??? -AsyncHttpClientMonixBackend.usingConfig(config).flatMap { backend => ??? } - -// or, if you'd like to use adjust the configuration sttp creates: -import org.asynchttpclient.DefaultAsyncHttpClientConfig -val sttpOptions: SttpBackendOptions = SttpBackendOptions.Default -val adjustFunction: DefaultAsyncHttpClientConfig.Builder => DefaultAsyncHttpClientConfig.Builder = ??? -AsyncHttpClientMonixBackend.usingConfigBuilder(adjustFunction, sttpOptions).flatMap { backend => ??? } - -// or, if you'd like to instantiate the AsyncHttpClient yourself: -import org.asynchttpclient.AsyncHttpClient -val asyncHttpClient: AsyncHttpClient = ??? -val backend = AsyncHttpClientMonixBackend.usingClient(asyncHttpClient) -``` ## Using OkHttp To use, add the following dependency to your project: ```scala -"com.softwaremill.sttp.client3" %% "okhttp-backend-monix" % "3.8.2" +"com.softwaremill.sttp.client3" %% "okhttp-backend-monix" % "3.8.3" ``` Create the backend using: @@ -108,7 +71,7 @@ This backend depends on [OkHttp](http://square.github.io/okhttp/) and fully supp To use, add the following dependency to your project: ``` -"com.softwaremill.sttp.client3" %% "armeria-backend-monix" % "3.8.2" +"com.softwaremill.sttp.client3" %% "armeria-backend-monix" % "3.8.3" ``` add imports: @@ -153,16 +116,16 @@ Please visit [the official documentation](https://armeria.dev/docs/client-factor ## Streaming -The Monix backends support streaming. The streams capability is represented as `sttp.client3.impl.monix.MonixStreams`. The type of supported streams in this case is `Observable[ByteBuffer]`. That is, you can set such an observable as a request body (using the async-http-client backend as an example, but any of the above backends can be used): +The Monix backends support streaming. The streams capability is represented as `sttp.client3.impl.monix.MonixStreams`. The type of supported streams in this case is `Observable[ByteBuffer]`. That is, you can set such an observable as a request body (using the http-client backend as an example, but any of the above backends can be used): ```scala import sttp.capabilities.monix.MonixStreams import sttp.client3._ -import sttp.client3.asynchttpclient.monix._ +import sttp.client3.httpclient.monix.HttpClientMonixBackend import monix.reactive.Observable -AsyncHttpClientMonixBackend().flatMap { backend => +HttpClientMonixBackend().flatMap { backend => val obs: Observable[Array[Byte]] = ??? basicRequest @@ -177,13 +140,13 @@ And receive responses as an observable stream: ```scala import sttp.capabilities.monix.MonixStreams import sttp.client3._ -import sttp.client3.asynchttpclient.monix._ +import sttp.client3.httpclient.monix.HttpClientMonixBackend import monix.eval.Task import monix.reactive.Observable import scala.concurrent.duration.Duration -AsyncHttpClientMonixBackend().flatMap { backend => +HttpClientMonixBackend().flatMap { backend => val response: Task[Response[Either[String, Observable[Array[Byte]]]]] = basicRequest .post(uri"...") diff --git a/generated-docs/out/backends/native/curl.md b/generated-docs/out/backends/native/curl.md index e564042ae3..74a368d4c3 100644 --- a/generated-docs/out/backends/native/curl.md +++ b/generated-docs/out/backends/native/curl.md @@ -5,7 +5,7 @@ A Scala Native backend implemented using [Curl](https://github.com/curl/curl/blo To use, add the following dependency to your project: ``` -"com.softwaremill.sttp.client3" %%% "core" % "3.8.2" +"com.softwaremill.sttp.client3" %%% "core" % "3.8.3" ``` and initialize one of the backends: diff --git a/generated-docs/out/backends/scalaz.md b/generated-docs/out/backends/scalaz.md index 966c2eaee3..79282688ba 100644 --- a/generated-docs/out/backends/scalaz.md +++ b/generated-docs/out/backends/scalaz.md @@ -2,50 +2,13 @@ The [Scalaz](https://github.com/scalaz/scalaz) backend is **asynchronous**. Sending a request is a non-blocking, lazily-evaluated operation and results in a response wrapped in a `scalaz.concurrent.Task`. There's a transitive dependency on `scalaz-concurrent`. -## Using async-http-client - -To use, add the following dependency to your project: - -```scala -"com.softwaremill.sttp.client3" %% "async-http-client-backend-scalaz" % "3.8.2" -``` - -This backend depends on [async-http-client](https://github.com/AsyncHttpClient/async-http-client) and uses [Netty](http://netty.io) behind the scenes. - -Next you'll need to add an implicit value: - -```scala -import sttp.client3._ -import sttp.client3.asynchttpclient.scalaz.AsyncHttpClientScalazBackend - -AsyncHttpClientScalazBackend().flatMap { backend => ??? } - -// or, if you'd like to use custom configuration: -import org.asynchttpclient.AsyncHttpClientConfig -val config: AsyncHttpClientConfig = ??? - -AsyncHttpClientScalazBackend.usingConfig(config).flatMap { backend => ??? } - -// or, if you'd like to use adjust the configuration sttp creates: -import org.asynchttpclient.DefaultAsyncHttpClientConfig -val sttpOptions: SttpBackendOptions = SttpBackendOptions.Default -val adjustFunction: DefaultAsyncHttpClientConfig.Builder => DefaultAsyncHttpClientConfig.Builder = ??? - -AsyncHttpClientScalazBackend.usingConfigBuilder(adjustFunction, sttpOptions).flatMap { backend => ??? } - -// or, if you'd like to instantiate the AsyncHttpClient yourself: -import org.asynchttpclient.AsyncHttpClient -val asyncHttpClient: AsyncHttpClient = ??? - -val backend = AsyncHttpClientScalazBackend.usingClient(asyncHttpClient) -``` ## Using Armeria To use, add the following dependency to your project: ``` -"com.softwaremill.sttp.client3" %% "armeria-backend-scalaz" % "3.8.2" +"com.softwaremill.sttp.client3" %% "armeria-backend-scalaz" % "3.8.3" ``` add imports: diff --git a/generated-docs/out/backends/summary.md b/generated-docs/out/backends/summary.md index b1b252e4a6..2f143e4b97 100644 --- a/generated-docs/out/backends/summary.md +++ b/generated-docs/out/backends/summary.md @@ -30,12 +30,6 @@ Class Effect type Supported ``HttpURLConnectionBackend`` None (``Identity``) n/a no no ``TryHttpURLConnectionBackend`` ``scala.util.Try`` n/a no no ``AkkaHttpBackend`` ``scala.concurrent.Future`` ``akka.stream.scaladsl.Source[ByteString, Any]`` yes (regular & streaming) yes -``AsyncHttpClientFutureBackend`` ``scala.concurrent.Future`` n/a yes (regular) no -``AsyncHttpClientScalazBackend`` ``scalaz.concurrent.Task`` n/a yes (regular) no -``AsyncHttpClientZioBackend`` ``zio.Task`` ``zio.stream.Stream[Throwable, Byte]`` yes (regular & streaming) no -``AsyncHttpClientMonixBackend`` ``monix.eval.Task`` ``monix.reactive.Observable[ByteBuffer]`` yes (regular & streaming) no -``AsyncHttpClientCatsBackend`` ``F[_]: cats.effect.Concurrent`` n/a no no -``AsyncHttpClientFs2Backend`` ``F[_]: cats.effect.Concurrent`` ``fs2.Stream[F, Byte]`` yes (regular & streaming) no ``ArmeriaFutureBackend`` ``scala.concurrent.Future`` n/a no yes ``ArmeriaScalazBackend`` ``scalaz.concurrent.Task`` n/a no yes ``ArmeriaZioBackend`` ``zio.Task`` ``zio.stream.Stream[Throwable, Byte]`` no yes @@ -50,6 +44,21 @@ Class Effect type Supported ==================================== ================================ ================================================= ========================== =================== ``` +Moreover, the following backends are deprecated, as they depend on async-http-client, which is no longer maintained: + +```eval_rst +==================================== ================================ ================================================= ========================== =================== +Class Effect type Supported stream type Supports websockets Fully non-blocking +==================================== ================================ ================================================= ========================== =================== +``AsyncHttpClientFutureBackend`` ``scala.concurrent.Future`` n/a yes (regular) no +``AsyncHttpClientScalazBackend`` ``scalaz.concurrent.Task`` n/a yes (regular) no +``AsyncHttpClientZioBackend`` ``zio.Task`` ``zio.stream.Stream[Throwable, Byte]`` yes (regular & streaming) no +``AsyncHttpClientMonixBackend`` ``monix.eval.Task`` ``monix.reactive.Observable[ByteBuffer]`` yes (regular & streaming) no +``AsyncHttpClientCatsBackend`` ``F[_]: cats.effect.Concurrent`` n/a no no +``AsyncHttpClientFs2Backend`` ``F[_]: cats.effect.Concurrent`` ``fs2.Stream[F, Byte]`` yes (regular & streaming) no +==================================== ================================ ================================================= ========================== =================== +``` + The backends work with Scala 2.11, 2.12, 2.13 and 3 (with some exceptions for 2.11 and 3). Backends supporting cats-effect are available in versions for cats-effect 2.x (dependency artifacts have the `-ce2` suffix) and 3.x. diff --git a/generated-docs/out/backends/synchronous.md b/generated-docs/out/backends/synchronous.md index 5c189ae229..bc62b503c5 100644 --- a/generated-docs/out/backends/synchronous.md +++ b/generated-docs/out/backends/synchronous.md @@ -7,7 +7,7 @@ There are several synchronous backend implementations. Sending a request using t The default **synchronous** backend. To use, you don't need any extra dependencies, `core` is enough: ``` -"com.softwaremill.sttp.client3" %% "core" % "3.8.2" +"com.softwaremill.sttp.client3" %% "core" % "3.8.3" ``` Create the backend using: @@ -40,7 +40,7 @@ Host header override is supported in environments running Java 12 onwards, but i To use, you don't need any extra dependencies, `core` is enough: ``` -"com.softwaremill.sttp.client3" %% "core" % "3.8.2" +"com.softwaremill.sttp.client3" %% "core" % "3.8.3" ``` Create the backend using: @@ -62,7 +62,7 @@ This backend supports host header override, but it has to be enabled by system p To use, add the following dependency to your project: ``` -"com.softwaremill.sttp.client3" %% "okhttp-backend" % "3.8.2" +"com.softwaremill.sttp.client3" %% "okhttp-backend" % "3.8.3" ``` Create the backend using: diff --git a/generated-docs/out/backends/wrappers/custom.md b/generated-docs/out/backends/wrappers/custom.md index a3bc240a25..c3a5caaa71 100644 --- a/generated-docs/out/backends/wrappers/custom.md +++ b/generated-docs/out/backends/wrappers/custom.md @@ -238,7 +238,7 @@ object RateLimitingSttpBackend { Implementing a new backend is made easy as the tests are published in the `core` jar file under the `tests` classifier. Simply add the follow dependencies to your `build.sbt`: ``` -"com.softwaremill.sttp.client3" %% "core" % "3.8.2" % Test classifier "tests" +"com.softwaremill.sttp.client3" %% "core" % "3.8.3" % Test classifier "tests" ``` Implement your backend and extend the `HttpTest` class: @@ -265,4 +265,13 @@ When implementing a backend wrapper using cats, it might be useful to import: import sttp.client3.impl.cats.implicits._ ``` -from the cats integration module. The module should be available on the classpath when using the cats [async-http-client](../catseffect.md) backend. The object contains implicits to convert a cats `MonadError` into the sttp `MonadError`, as well as a way to map the effects wrapper used with the `.mapK` extension method for the backend. +from the cats integration module. The module should be available on the classpath after adding following dependency: + +```scala +"com.softwaremill.sttp.client3" %% "cats" % "3.8.3" // for cats-effect 3.x +// or +"com.softwaremill.sttp.client3" %% "catsce2" % "3.8.3" // for cats-effect 2.x +``` + +The object contains implicits to convert a cats `MonadError` into the sttp `MonadError`, +as well as a way to map the effects wrapper used with the `.mapK` extension method for the backend. diff --git a/generated-docs/out/backends/wrappers/logging.md b/generated-docs/out/backends/wrappers/logging.md index 99cff3a67d..098b35202a 100644 --- a/generated-docs/out/backends/wrappers/logging.md +++ b/generated-docs/out/backends/wrappers/logging.md @@ -28,7 +28,7 @@ Log levels can be configured when creating the `LoggingBackend`, or specified in To use the [slf4j](http://www.slf4j.org) logging backend wrapper, add the following dependency to your project: ``` -"com.softwaremill.sttp.client3" %% "slf4j-backend" % "3.8.2" +"com.softwaremill.sttp.client3" %% "slf4j-backend" % "3.8.3" ``` There are three backend wrappers available, which log request & response information using a slf4j `Logger`. To see the logs, you'll need to use an slf4j-compatible logger implementation, e.g. [logback](http://logback.qos.ch), or use a binding, e.g. [log4j-slf4j](https://logging.apache.org/log4j/2.0/log4j-slf4j-impl/index.html). @@ -50,5 +50,5 @@ To create a customised logging backend, see the section on [custom backends](cus To use the [scribe](https://github.com/outr/scribe) logging backend wrapper, add the following dependency to your project: ``` -"com.softwaremill.sttp.client3" %% "scribe-backend" % "3.8.2" +"com.softwaremill.sttp.client3" %% "scribe-backend" % "3.8.3" ``` \ No newline at end of file diff --git a/generated-docs/out/backends/wrappers/opentelemetry.md b/generated-docs/out/backends/wrappers/opentelemetry.md index 8a22a968c2..f177febb15 100644 --- a/generated-docs/out/backends/wrappers/opentelemetry.md +++ b/generated-docs/out/backends/wrappers/opentelemetry.md @@ -12,7 +12,7 @@ The backend depends only on [opentelemetry-api](https://github.com/open-telemetr following dependency to your project: ``` -"com.softwaremill.sttp.client3" %% "opentelemetry-metrics-backend" % "3.8.2" +"com.softwaremill.sttp.client3" %% "opentelemetry-metrics-backend" % "3.8.3" ``` Then an instance can be obtained as follows: @@ -53,8 +53,8 @@ OpenTelemetryMetricsBackend( To use, add the following dependency to your project (the `zio-*` modules depend on ZIO 2.x; for ZIO 1.x support, use `zio1-*`): ``` -"com.softwaremill.sttp.client3" %% "opentelemetry-tracing-zio-backend" % "3.8.2" // for ZIO 2.x -"com.softwaremill.sttp.client3" %% "opentelemetry-tracing-zio1-backend" % "3.8.2" // for ZIO 1.x +"com.softwaremill.sttp.client3" %% "opentelemetry-tracing-zio-backend" % "3.8.3" // for ZIO 2.x +"com.softwaremill.sttp.client3" %% "opentelemetry-tracing-zio1-backend" % "3.8.3" // for ZIO 1.x ``` This backend depends on [zio-opentelemetry](https://github.com/zio/zio-telemetry). diff --git a/generated-docs/out/backends/wrappers/prometheus.md b/generated-docs/out/backends/wrappers/prometheus.md index 6bdf4929da..ab29bd063a 100644 --- a/generated-docs/out/backends/wrappers/prometheus.md +++ b/generated-docs/out/backends/wrappers/prometheus.md @@ -3,7 +3,7 @@ To use, add the following dependency to your project: ``` -"com.softwaremill.sttp.client3" %% "prometheus-backend" % "3.8.2" +"com.softwaremill.sttp.client3" %% "prometheus-backend" % "3.8.3" ``` and some imports: diff --git a/generated-docs/out/backends/zio.md b/generated-docs/out/backends/zio.md index f0cf8ffeb7..67f5ed69d1 100644 --- a/generated-docs/out/backends/zio.md +++ b/generated-docs/out/backends/zio.md @@ -9,8 +9,8 @@ The `*-zio` modules depend on ZIO 2.x. For ZIO 1.x support, use modules with the To use, add the following dependency to your project: ``` -"com.softwaremill.sttp.client3" %% "zio" % "3.8.2" // for ZIO 2.x -"com.softwaremill.sttp.client3" %% "zio1" % "3.8.2" // for ZIO 1.x +"com.softwaremill.sttp.client3" %% "zio" % "3.8.3" // for ZIO 2.x +"com.softwaremill.sttp.client3" %% "zio1" % "3.8.3" // for ZIO 1.x ``` Create the backend using: @@ -37,55 +37,14 @@ Host header override is supported in environments running Java 12 onwards, but i -Djdk.httpclient.allowRestrictedHeaders=host ``` -## Using async-http-client - -To use, add the following dependency to your project: - -```scala -"com.softwaremill.sttp.client3" %% "async-http-client-backend-zio" % "3.8.2" // for ZIO 2.x -"com.softwaremill.sttp.client3" %% "async-http-client-backend-zio1" % "3.8.2" // for ZIO 1.x -``` - -This backend depends on [async-http-client](https://github.com/AsyncHttpClient/async-http-client), uses [Netty](http://netty.io) behind the scenes. This backend works with all Scala versions. A Scala 3 build is available as well. - -Next you'll need to define a backend instance. A non-comprehensive summary of how this can be done is as follows: - -```scala -import sttp.client3._ -import sttp.client3.asynchttpclient.zio.AsyncHttpClientZioBackend - -AsyncHttpClientZioBackend().flatMap { backend => ??? } - -// or, if you'd like the backend to be wrapped in a Scope: -AsyncHttpClientZioBackend.scoped().flatMap { backend => ??? } - -// or, if you'd like to use custom configuration: -import org.asynchttpclient.AsyncHttpClientConfig -val config: AsyncHttpClientConfig = ??? -AsyncHttpClientZioBackend.usingConfig(config).flatMap { backend => ??? } - -// or, if you'd like to use adjust the configuration sttp creates: -import org.asynchttpclient.DefaultAsyncHttpClientConfig -val sttpOptions: SttpBackendOptions = SttpBackendOptions.Default -val adjustFunction: DefaultAsyncHttpClientConfig.Builder => DefaultAsyncHttpClientConfig.Builder = ??? - -AsyncHttpClientZioBackend.usingConfigBuilder(adjustFunction, sttpOptions).flatMap { backend => ??? } - -// or, if you'd like to instantiate the AsyncHttpClient yourself: -import org.asynchttpclient.AsyncHttpClient -import zio.Runtime -val asyncHttpClient: AsyncHttpClient = ??? -val runtime: Runtime[Any] = ??? -val backend = AsyncHttpClientZioBackend.usingClient(runtime, asyncHttpClient) -``` ## Using Armeria To use, add the following dependency to your project: ``` -"com.softwaremill.sttp.client3" %% "armeria-backend-zio" % "3.8.2" // for ZIO 2.x -"com.softwaremill.sttp.client3" %% "armeria-backend-zio1" % "3.8.2" // for ZIO 1.x +"com.softwaremill.sttp.client3" %% "armeria-backend-zio" % "3.8.3" // for ZIO 2.x +"com.softwaremill.sttp.client3" %% "armeria-backend-zio1" % "3.8.3" // for ZIO 1.x ``` add imports: @@ -136,7 +95,7 @@ Please visit [the official documentation](https://armeria.dev/docs/client-factor ## ZIO layers -As an alternative to effectfully or resourcefully creating backend instances, ZIO layers can be used. In this scenario, the lifecycle of a `SttpBackend` service is described by `ZLayer`s, which can be created using the `.layer`/`.layerUsingConfig`/... methods on `HttpClientZioBackend` / `AsyncHttpClientZioBackend` / `ArmeriaZioBackend`. +As an alternative to effectfully or resourcefully creating backend instances, ZIO layers can be used. In this scenario, the lifecycle of a `SttpBackend` service is described by `ZLayer`s, which can be created using the `.layer`/`.layerUsingConfig`/... methods on `HttpClientZioBackend` / `ArmeriaZioBackend`. The layers can be used to provide an implementation of the `SttpBackend` dependency when creating services. For example: @@ -161,7 +120,7 @@ ZLayer.make[MyService](MyService.live, HttpClientZioBackend.layer()) ## Streaming -The ZIO based backends support streaming using zio-streams. The following example is using the `AsyncHttpClientZioBackend` backend, but works similarly with `HttpClientZioBackend`. +The ZIO based backends support streaming using zio-streams. The following example is using the `HttpClientZioBackend`. The type of supported streams is `Stream[Throwable, Byte]`. The streams capability is represented as `sttp.client3.impl.zio.ZioStreams`. To leverage ZIO environment, use the `SttpClient` object to create request send effects. @@ -207,7 +166,7 @@ val response: ZIO[Any, Throwable, Response[Either[String, Stream[Throwable, Byte ## Websockets -The `HttpClient` and `async-http-client` ZIO backends support both regular and streaming [websockets](../websockets.md). +The `HttpClient` ZIO backend supports both regular and streaming [websockets](../websockets.md). ## Testing diff --git a/generated-docs/out/conf/ssl.md b/generated-docs/out/conf/ssl.md index 0e2f3e08bf..23fd5f02bb 100644 --- a/generated-docs/out/conf/ssl.md +++ b/generated-docs/out/conf/ssl.md @@ -94,28 +94,6 @@ val backend = AkkaHttpBackend.usingActorSystem(actorSystem, customHttpsContext = For more information refer to [akka docs](https://doc.akka.io/docs/akka-http/current/client-side/client-https-support.html). -## Using Async-http-client - -Using `kmf: KeyManagerFactory` and `tmf: TrustManagerFactory` from [first section](#ssl-context) create a `AsyncHttpClientConfig`. - -Backends using `AsyncHttpClient` provides factory methods accepting custom config. - - -```scala -import io.netty.handler.ssl.SslContextBuilder -import org.asynchttpclient.{AsyncHttpClientConfig, DefaultAsyncHttpClientConfig} -import sttp.client3.asynchttpclient.future._ - -val sslContext = SslContextBuilder.forClient() - .keyManager(kmf) - .trustManager(tmf) - .build() - -val config: AsyncHttpClientConfig = new DefaultAsyncHttpClientConfig.Builder().setSslContext(sslContext).build() - -val backend = AsyncHttpClientFutureBackend.usingConfig(config) -``` - ## Using OkHttp Using `SSLContext` from [first section](#ssl-context) create a `OkHttpClient`. @@ -159,3 +137,29 @@ import sttp.client3.httpclient.fs2.HttpClientFs2Backend val httpClient: HttpClient = HttpClient.newBuilder().sslContext(ssl).build() val backend: Resource[IO, SttpBackend[IO, Fs2Streams[IO] with WebSockets]] = Dispatcher[IO].map(HttpClientFs2Backend.usingClient[IO](httpClient, _)) ``` + +## Using Async-http-client (deprecated) + +```eval_rst +.. note:: Note that the async-http-client is no longer maintained, thus backends based on it should not be used in the new projects. +``` + +Using `kmf: KeyManagerFactory` and `tmf: TrustManagerFactory` from [first section](#ssl-context) create a `AsyncHttpClientConfig`. + +Backends using `AsyncHttpClient` provides factory methods accepting custom config. + + +```scala +import io.netty.handler.ssl.SslContextBuilder +import org.asynchttpclient.{AsyncHttpClientConfig, DefaultAsyncHttpClientConfig} +import sttp.client3.asynchttpclient.future._ + +val sslContext = SslContextBuilder.forClient() + .keyManager(kmf) + .trustManager(tmf) + .build() + +val config: AsyncHttpClientConfig = new DefaultAsyncHttpClientConfig.Builder().setSslContext(sslContext).build() + +val backend = AsyncHttpClientFutureBackend.usingConfig(config) +``` diff --git a/generated-docs/out/examples.md b/generated-docs/out/examples.md index 140477289c..0367c9db7a 100644 --- a/generated-docs/out/examples.md +++ b/generated-docs/out/examples.md @@ -7,7 +7,7 @@ All of the examples are available [in the sources](https://github.com/softwaremi Required dependencies: ```scala -libraryDependencies ++= List("com.softwaremill.sttp.client3" %% "core" % "3.8.2") +libraryDependencies ++= List("com.softwaremill.sttp.client3" %% "core" % "3.8.3") ``` Example code: @@ -22,7 +22,7 @@ Example code: Required dependencies: ```scala -libraryDependencies ++= List("com.softwaremill.sttp.client3" %% "core" % "3.8.2") +libraryDependencies ++= List("com.softwaremill.sttp.client3" %% "core" % "3.8.3") ``` Example code: @@ -38,8 +38,8 @@ Required dependencies: ```scala libraryDependencies ++= List( - "com.softwaremill.sttp.client3" %% "akka-http-backend" % "3.8.2", - "com.softwaremill.sttp.client3" %% "json4s" % "3.8.2", + "com.softwaremill.sttp.client3" %% "akka-http-backend" % "3.8.3", + "com.softwaremill.sttp.client3" %% "json4s" % "3.8.3", "org.json4s" %% "json4s-native" % "3.6.0" ) ``` @@ -51,14 +51,14 @@ Example code: :language: scala ``` -## GET and parse JSON using the ZIO async-http-client backend and circe +## GET and parse JSON using the ZIO http-client backend and circe Required dependencies: ```scala libraryDependencies ++= List( - "com.softwaremill.sttp.client3" %% "async-http-client-backend-zio" % "3.8.2", - "com.softwaremill.sttp.client3" %% "circe" % "3.8.2", + "com.softwaremill.sttp.client3" %% "zio" % "3.8.3", + "com.softwaremill.sttp.client3" %% "circe" % "3.8.3", "io.circe" %% "circe-generic" % "0.14.1" ) ``` @@ -70,14 +70,14 @@ Example code: :language: scala ``` -## GET and parse JSON using the async-http-client Monix backend and circe, treating deserialization errors as failed effects +## GET and parse JSON using the http-client Monix backend and circe, treating deserialization errors as failed effects Required dependencies: ```scala libraryDependencies ++= List( - "com.softwaremill.sttp.client3" %% "async-http-client-backend-monix" % "3.8.2", - "com.softwaremill.sttp.client3" %% "circe" % "3.8.2", + "com.softwaremill.sttp.client3" %% "monix" % "3.8.3", + "com.softwaremill.sttp.client3" %% "circe" % "3.8.3", "io.circe" %% "circe-generic" % "0.14.1" ) ``` @@ -95,8 +95,8 @@ Required dependencies: ```scala libraryDependencies ++= List( - "com.softwaremill.sttp.client3" %% "slf4j-backend" % "3.8.2", - "com.softwaremill.sttp.client3" %% "circe" % "3.8.2", + "com.softwaremill.sttp.client3" %% "slf4j-backend" % "3.8.3", + "com.softwaremill.sttp.client3" %% "circe" % "3.8.3", "io.circe" %% "circe-generic" % "0.14.1" ) ``` @@ -108,14 +108,14 @@ Example code: :language: scala ``` -## POST and serialize JSON using the Monix async-http-client backend and circe +## POST and serialize JSON using the Monix http-client backend and circe Required dependencies: ```scala libraryDependencies ++= List( - "com.softwaremill.sttp.client3" %% "async-http-client-backend-monix" % "3.8.2", - "com.softwaremill.sttp.client3" %% "circe" % "3.8.2", + "com.softwaremill.sttp.client3" %% "monix" % "3.8.3", + "com.softwaremill.sttp.client3" %% "circe" % "3.8.3", "io.circe" %% "circe-generic" % "0.14.1" ) ``` @@ -123,7 +123,7 @@ libraryDependencies ++= List( Example code: ```eval_rst -.. literalinclude:: ../../examples-ce2/src/main/scala/sttp/client3/examples/PostSerializeJsonMonixAsyncHttpClientCirce.scala +.. literalinclude:: ../../examples-ce2/src/main/scala/sttp/client3/examples/PostSerializeJsonMonixHttpClientCirce.scala :language: scala ``` @@ -132,7 +132,7 @@ Example code: Required dependencies: ```scala -libraryDependencies ++= List("com.softwaremill.sttp.client3" %% "core" % "3.8.2") +libraryDependencies ++= List("com.softwaremill.sttp.client3" %% "core" % "3.8.3") ``` Example code: @@ -141,13 +141,12 @@ Example code: .. literalinclude:: ../../examples/src/main/scala/sttp/client3/examples/TestEndpointMultipleQueryParameters.scala :language: scala ``` - ## Open a websocket using ZIO Required dependencies: ```scala -libraryDependencies ++= List("com.softwaremill.sttp.client3" %% "async-http-client-backend-zio" % "3.8.2") +libraryDependencies ++= List("com.softwaremill.sttp.client3" %% "zio" % "3.8.3") ``` Example code: @@ -162,7 +161,7 @@ Example code: Required dependencies: ```scala -libraryDependencies ++= List("com.softwaremill.sttp.client3" %% "async-http-client-backend-fs2" % "3.8.2") +libraryDependencies ++= List("com.softwaremill.sttp.client3" %% "fs2" % "3.8.3") ``` Example code: @@ -177,7 +176,7 @@ Example code: Required dependencies: ```scala -libraryDependencies ++= List("com.softwaremill.sttp.client3" %% "async-http-client-backend-monix" % "3.8.2") +libraryDependencies ++= List("com.softwaremill.sttp.client3" %% "monix" % "3.8.3") ``` Example code: @@ -192,7 +191,7 @@ Example code: Required dependencies: ```scala -libraryDependencies ++= List("com.softwaremill.sttp.client3" %% "akka-http-backend" % "3.8.2") +libraryDependencies ++= List("com.softwaremill.sttp.client3" %% "akka-http-backend" % "3.8.3") ``` Example code: @@ -207,7 +206,7 @@ Example code: Required dependencies: ```scala -libraryDependencies ++= List("com.softwaremill.sttp.client3" %% "async-http-client-backend-monix" % "3.8.2") +libraryDependencies ++= List("com.softwaremill.sttp.client3" %% "monix" % "3.8.3") ``` Example code: @@ -222,7 +221,7 @@ Example code: Required dependencies: ```scala -libraryDependencies ++= List("com.softwaremill.sttp.client3" %% "async-http-client-backend-fs2" % "3.8.2") +libraryDependencies ++= List("com.softwaremill.sttp.client3" %% "fs2" % "3.8.3") ``` Example code: @@ -237,7 +236,7 @@ Example code: Required dependencies: ```scala -libraryDependencies ++= List("com.softwaremill.sttp.client3" %% "async-http-client-backend-zio" % "3.8.2") +libraryDependencies ++= List("com.softwaremill.sttp.client3" %% "zio" % "3.8.3") ``` Example code: @@ -252,7 +251,7 @@ Example code: Required dependencies: ```scala -libraryDependencies ++= List("com.softwaremill.sttp.client3" %% "async-http-client-backend-zio" % "3.8.2") +libraryDependencies ++= List("com.softwaremill.sttp.client3" %% "zio" % "3.8.3") ``` Example code: @@ -267,7 +266,7 @@ Example code: Required dependencies: ```scala -libraryDependencies ++= List("com.softwaremill.sttp.client3" %% "core" % "3.8.2") +libraryDependencies ++= List("com.softwaremill.sttp.client3" %% "core" % "3.8.3") ``` Example code: diff --git a/generated-docs/out/index.md b/generated-docs/out/index.md index f23a884d8e..5e73b2a1cf 100644 --- a/generated-docs/out/index.md +++ b/generated-docs/out/index.md @@ -5,7 +5,7 @@ Welcome! [sttp client](https://github.com/softwaremill/sttp) is an open-source library which provides a clean, programmer-friendly API to describe HTTP requests and how to handle responses. Requests are sent using one of the backends, which wrap other Scala or Java HTTP client implementations. The backends can integrate with a variety of Scala stacks, providing both synchronous and asynchronous, procedural and functional interfaces. -Backend implementations include ones based on [akka-http](https://doc.akka.io/docs/akka-http/current/scala/http/), [async-http-client](https://github.com/AsyncHttpClient/async-http-client), [http4s](https://http4s.org), [OkHttp](http://square.github.io/okhttp/), and HTTP clients which ship with Java. They integrate with [Akka](https://akka.io), [Monix](https://monix.io), [fs2](https://github.com/functional-streams-for-scala/fs2), [cats-effect](https://github.com/typelevel/cats-effect), [scalaz](https://github.com/scalaz/scalaz) and [ZIO](https://github.com/zio/zio). Supported Scala versions include 2.11, 2.12, 2.13 and 3, Scala.JS and Scala Native. +Backend implementations include ones based on [akka-http](https://doc.akka.io/docs/akka-http/current/scala/http/), [http4s](https://http4s.org), [OkHttp](http://square.github.io/okhttp/), and HTTP clients which ship with Java. They integrate with [Akka](https://akka.io), [Monix](https://monix.io), [fs2](https://github.com/functional-streams-for-scala/fs2), [cats-effect](https://github.com/typelevel/cats-effect), [scalaz](https://github.com/scalaz/scalaz) and [ZIO](https://github.com/zio/zio). Supported Scala versions include 2.11, 2.12, 2.13 and 3, Scala.JS and Scala Native. Here's a quick example of sttp client in action: diff --git a/generated-docs/out/json.md b/generated-docs/out/json.md index 0b6ff87d9e..b033d0a0bb 100644 --- a/generated-docs/out/json.md +++ b/generated-docs/out/json.md @@ -34,7 +34,7 @@ case class ResponsePayload(data: String) JSON encoding of bodies and decoding of responses can be handled using [Circe](https://circe.github.io/circe/) by the `circe` module. To use add the following dependency to your project: ```scala -"com.softwaremill.sttp.client3" %% "circe" % "3.8.2" +"com.softwaremill.sttp.client3" %% "circe" % "3.8.3" ``` This module adds a body serialized, so that json payloads can be sent as request bodies. To send a payload of type `T` as json, a `io.circe.Encoder[T]` implicit value must be available in scope. @@ -66,7 +66,7 @@ Arbitrary JSON structures can be traversed by parsing the result as `io.circe.Js To encode and decode json using json4s, add the following dependency to your project: ``` -"com.softwaremill.sttp.client3" %% "json4s" % "3.8.2" +"com.softwaremill.sttp.client3" %% "json4s" % "3.8.3" "org.json4s" %% "json4s-native" % "3.6.0" ``` @@ -100,7 +100,7 @@ val response: Identity[Response[Either[ResponseException[String, Exception], Res To encode and decode JSON using [spray-json](https://github.com/spray/spray-json), add the following dependency to your project: ``` -"com.softwaremill.sttp.client3" %% "spray-json" % "3.8.2" +"com.softwaremill.sttp.client3" %% "spray-json" % "3.8.3" ``` Using this module it is possible to set request bodies and read response bodies as your custom types, using the implicitly available instances of `spray.json.JsonWriter` / `spray.json.JsonReader` or `spray.json.JsonFormat`. @@ -132,7 +132,7 @@ val response: Identity[Response[Either[ResponseException[String, Exception], Res To encode and decode JSON using [play-json](https://www.playframework.com), add the following dependency to your project: ```scala -"com.softwaremill.sttp.client3" %% "play-json" % "3.8.2" +"com.softwaremill.sttp.client3" %% "play-json" % "3.8.3" ``` To use, add an import: `import sttp.client3.playJson._`. @@ -144,13 +144,13 @@ To encode and decode JSON using the high-performance [zio-json](https://zio.gith The `zio-json` module depends on ZIO 2.x. For ZIO 1.x support, use `zio1-json`. ```scala -"com.softwaremill.sttp.client3" %% "zio-json" % "3.8.2" // for ZIO 2.x -"com.softwaremill.sttp.client3" %% "zio1-json" % "3.8.2" // for ZIO 1.x +"com.softwaremill.sttp.client3" %% "zio-json" % "3.8.3" // for ZIO 2.x +"com.softwaremill.sttp.client3" %% "zio1-json" % "3.8.3" // for ZIO 1.x ``` or for ScalaJS (cross build) projects: ```scala -"com.softwaremill.sttp.client3" %%% "zio-json" % "3.8.2" // for ZIO 2.x -"com.softwaremill.sttp.client3" %%% "zio1-json" % "3.8.2" // for ZIO 1.x +"com.softwaremill.sttp.client3" %%% "zio-json" % "3.8.3" // for ZIO 2.x +"com.softwaremill.sttp.client3" %%% "zio1-json" % "3.8.3" // for ZIO 1.x ``` To use, add an import: `import sttp.client3.ziojson._` (or extend `SttpZioJsonApi`), define an implicit `JsonCodec`, or `JsonDecoder`/`JsonEncoder` for your datatype. @@ -182,13 +182,13 @@ basicRequest To encode and decode JSON using the [high(est)-performant](https://plokhotnyuk.github.io/jsoniter-scala/) [jsoniter-scala](https://github.com/plokhotnyuk/jsoniter-scala) library, one add the following dependency to your project. ```scala -"com.softwaremill.sttp.client3" %% "jsoniter-json" % "3.8.2" +"com.softwaremill.sttp.client3" %% "jsoniter-json" % "3.8.3" ``` or for ScalaJS (cross build) projects: ```scala -"com.softwaremill.sttp.client3" %%% "jsoniter-json" % "3.8.2" +"com.softwaremill.sttp.client3" %%% "jsoniter-json" % "3.8.3" ``` To use, add an import: `import sttp.client3.jsoniter._` (or extend `SttpJsonIterJsonApi`), define an implicit `JsonCodec`, or `JsonDecoder`/`JsonEncoder` for your datatype. @@ -222,13 +222,13 @@ basicRequest To encode and decode JSON using the [uPickle](https://github.com/com-lihaoyi/upickle) library, add the following dependency to your project: ```scala -"com.softwaremill.sttp.client3" %% "upickle" % "3.8.2" +"com.softwaremill.sttp.client3" %% "upickle" % "3.8.3" ``` or for ScalaJS (cross build) projects: ```scala -"com.softwaremill.sttp.client3" %%% "upickle" % "3.8.2" +"com.softwaremill.sttp.client3" %%% "upickle" % "3.8.3" ``` To use, add an import: `import sttp.client3.upicklejson._` (or extend `SttpUpickleApi`) and define an implicit `ReadWriter` (or separately `Reader` and `Writer`) for your datatype. diff --git a/generated-docs/out/openapi.md b/generated-docs/out/openapi.md index 7ca3b75a2e..1b3d7aeb6c 100644 --- a/generated-docs/out/openapi.md +++ b/generated-docs/out/openapi.md @@ -45,8 +45,8 @@ lazy val petstoreApi: Project = project openApiGeneratorName := "scala-sttp", openApiOutputDir := baseDirectory.value.name, libraryDependencies ++= Seq( - "com.softwaremill.sttp.client3" %% "core" % "3.8.2", - "com.softwaremill.sttp.client3" %% "json4s" % "3.8.2", + "com.softwaremill.sttp.client3" %% "core" % "3.8.3", + "com.softwaremill.sttp.client3" %% "json4s" % "3.8.3", "org.json4s" %% "json4s-jackson" % "3.6.8" ) ) @@ -96,8 +96,8 @@ lazy val petstoreApi: Project = project openApiOutputDir := baseDirectory.value.name, openApiIgnoreFileOverride := s"${baseDirectory.in(ThisBuild).value.getPath}/openapi-ignore-file", libraryDependencies ++= Seq( - "com.softwaremill.sttp.client3" %% "core" % "3.8.2", - "com.softwaremill.sttp.client3" %% "json4s" % "3.8.2", + "com.softwaremill.sttp.client3" %% "core" % "3.8.3", + "com.softwaremill.sttp.client3" %% "json4s" % "3.8.3", "org.json4s" %% "json4s-jackson" % "3.6.8" ), (compile in Compile) := ((compile in Compile) dependsOn openApiGenerate).value, diff --git a/generated-docs/out/quickstart.md b/generated-docs/out/quickstart.md index f00a1e05eb..d8482687ca 100644 --- a/generated-docs/out/quickstart.md +++ b/generated-docs/out/quickstart.md @@ -14,7 +14,7 @@ platforms, and that each has its own dedicated set of backends. The basic dependency which provides the API, together with a synchronous and `Future`-based backends, is: ```scala -"com.softwaremill.sttp.client3" %% "core" % "3.8.2" +"com.softwaremill.sttp.client3" %% "core" % "3.8.3" ``` ## Simple synchronous client @@ -26,7 +26,7 @@ If you'd like to send some requests synchronously, take a look at the [simple sy If you are an [Ammonite](https://ammonite.io) user, you can quickly start experimenting with sttp by copy-pasting the following: ```scala -import $ivy.`com.softwaremill.sttp.client3::core:3.8.2` +import $ivy.`com.softwaremill.sttp.client3::core:3.8.3` import sttp.client3.quick._ simpleSttpClient.send(quickRequest.get(uri"http://httpbin.org/ip")) ``` @@ -36,7 +36,7 @@ Importing the `quick` object has the same effect as importing `sttp.client3._`, If the default backend is for some reason insufficient, you can also use one based on OkHttp: ```scala -import $ivy.`com.softwaremill.sttp.client3::okhttp-backend:3.8.2` +import $ivy.`com.softwaremill.sttp.client3::okhttp-backend:3.8.3` import sttp.client3.okhttp.quick._ quickRequest.get(uri"http://httpbin.org/ip").send(backend) ``` diff --git a/generated-docs/out/resilience.md b/generated-docs/out/resilience.md index 233a29da4d..d68e14dd7d 100644 --- a/generated-docs/out/resilience.md +++ b/generated-docs/out/resilience.md @@ -32,7 +32,7 @@ Some backends have built-in retry mechanisms: * [akka-http](https://doc.akka.io/docs/akka-http/current/scala/http/client-side/host-level.html#retrying-a-request) * [OkHttp](http://square.github.io/okhttp) (see the builder's `retryOnConnectionFailure` method) -* async-http-client: by default, the backend will attempt 5 retries in case an `IOException` is thrown during the connection. This can be changed by specifying the `org.asynchttpclient.maxRequestRetry` config option, or by providing custom configuration using when creating the backend (`setMaxRequestRetry`). +* async-http-client (deprecated): by default, the backend will attempt 5 retries in case an `IOException` is thrown during the connection. This can be changed by specifying the `org.asynchttpclient.maxRequestRetry` config option, or by providing custom configuration using when creating the backend (`setMaxRequestRetry`). ## Circuit breaking diff --git a/generated-docs/out/simple_sync.md b/generated-docs/out/simple_sync.md index b9afb969dc..0b0237b58d 100644 --- a/generated-docs/out/simple_sync.md +++ b/generated-docs/out/simple_sync.md @@ -25,7 +25,7 @@ As an example, to integrate with the [uPickle](https://github.com/com-lihaoyi/up dependency: ```scala -"com.softwaremill.sttp.client3" %% "upickle" % "3.8.2" +"com.softwaremill.sttp.client3" %% "upickle" % "3.8.3" ``` Your code might then look as follows: @@ -62,7 +62,7 @@ Logging can be added using the [logging backend wrapper](backends/wrappers/loggi use slf4j, you'll need the following dependency: ``` -"com.softwaremill.sttp.client3" %% "slf4j-backend" % "3.8.2" +"com.softwaremill.sttp.client3" %% "slf4j-backend" % "3.8.3" ``` Then, you'll need to configure your client: diff --git a/generated-docs/out/testing.md b/generated-docs/out/testing.md index 5ace5ed028..234ec42190 100644 --- a/generated-docs/out/testing.md +++ b/generated-docs/out/testing.md @@ -8,7 +8,7 @@ You can also create a stub backend using [akka-http routes](backends/akka.md). An empty backend stub can be created using the following ways: -* by calling `.stub` on the "real" base backend's companion object, e.g. `AsyncHttpClientZioBackend.stub` or `HttpClientMonixBackend.stub` +* by calling `.stub` on the "real" base backend's companion object, e.g. `HttpClientZioBackend.stub` or `HttpClientMonixBackend.stub` * by using one of the factory methods `SttpBackendStub.synchronous` or `SttpBackendStub.asynchronousFuture`, which return stubs which use the `Identity` or standard Scala's `Future` effects without streaming support * by explicitly specifying the effect and supported capabilities: * for Monix `SttpBackendStub[Task, MonixStreams with WebSockets](TaskMonad)` diff --git a/generated-docs/out/websockets.md b/generated-docs/out/websockets.md index 46ea27da72..455947af48 100644 --- a/generated-docs/out/websockets.md +++ b/generated-docs/out/websockets.md @@ -91,20 +91,24 @@ configuring individual backends for more information. ## Implementation-specific configuration -### async-http-client based backends +### OkHttp based backends -Web socket settings can be adjusted by providing a custom `AsyncHttpClientConfig`, which can be created using -`new DefaultAsyncHttpClientConfig.Builder()`. +* supports compression (default: not enabled) -Some available settings: +### akka-http backend -* maximum web socket frame size. Default: 10240, can be changed using `.setWebSocketMaxFrameSize`. -* compression. Default: false, can be changed using: `.setEnablewebSocketCompression`. +Compression is not yet available, to track Akka developments in this area, see [this issue](https://github.com/akka/akka-http/issues/659). -### OkHttp based backends +### async-http-client based backends (deprecated) -* supports compression (default: not enabled) +```eval_rst +.. note:: Note that the async-http-client is no longer maintained, thus backends based on it should not be used in the new projects. +``` -### akka-http backend +Web socket settings can be adjusted by providing a custom `AsyncHttpClientConfig`, which can be created using +`new DefaultAsyncHttpClientConfig.Builder()`. + +Some available settings: -Compression is not yet available, to track Akka developments in this area, see [this issue](https://github.com/akka/akka-http/issues/659). \ No newline at end of file +* maximum web socket frame size. Default: 10240, can be changed using `.setWebSocketMaxFrameSize`. +* compression. Default: false, can be changed using: `.setEnablewebSocketCompression`. \ No newline at end of file