From 89543df93b1cb615c5ee589e92bb9ce2ad0b720d Mon Sep 17 00:00:00 2001 From: adamw Date: Tue, 31 Dec 2024 09:52:58 +0100 Subject: [PATCH] Release 4.0.0-M21 --- README.md | 12 ++++---- generated-docs/out/backends/akka.md | 2 +- generated-docs/out/backends/catseffect.md | 6 ++-- generated-docs/out/backends/finagle.md | 2 +- generated-docs/out/backends/fs2.md | 8 ++--- generated-docs/out/backends/future.md | 6 ++-- generated-docs/out/backends/http4s.md | 4 +-- .../out/backends/javascript/fetch.md | 12 ++++---- generated-docs/out/backends/monix.md | 6 ++-- generated-docs/out/backends/native/curl.md | 2 +- generated-docs/out/backends/pekko.md | 2 +- generated-docs/out/backends/scalaz.md | 2 +- generated-docs/out/backends/synchronous.md | 8 ++--- .../out/backends/wrappers/custom.md | 6 ++-- .../out/backends/wrappers/logging.md | 4 +-- .../out/backends/wrappers/opentelemetry.md | 4 +-- .../out/backends/wrappers/prometheus.md | 2 +- generated-docs/out/backends/zio.md | 8 ++--- generated-docs/out/includes/examples_list.md | 6 ++-- generated-docs/out/index.md | 29 ++++++++++--------- generated-docs/out/json.md | 26 ++++++++--------- generated-docs/out/openapi.md | 8 ++--- generated-docs/out/quickstart.md | 10 +++---- generated-docs/out/requests/body.md | 10 +++++++ generated-docs/out/responses/body.md | 11 +++++++ generated-docs/out/websockets.md | 2 +- 26 files changed, 110 insertions(+), 88 deletions(-) diff --git a/README.md b/README.md index ccf6de0b0..d0f76294f 100755 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Backend implementations include the HTTP client that is shipped with Java, as we Here's a quick example of sttp client in action, runnable using [scala-cli](https://scala-cli.virtuslab.org): ```scala -//> using dep com.softwaremill.sttp.client4::core:4.0.0-M20 +//> using dep com.softwaremill.sttp.client4::core:4.0.0-M21 import sttp.client4.* @@ -51,7 +51,7 @@ sttp (v2) documentation is available at [sttp.softwaremill.com/en/v2](https://st 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.client4/core_2.12/4.0.0-M20) +scaladoc is available at [https://www.javadoc.io](https://www.javadoc.io/doc/com.softwaremill.sttp.client4/core_2.12/4.0.0-M21) ## Quickstart with scala-cli @@ -59,7 +59,7 @@ Add the following directive to the top of your scala file to add the core sttp d If you are using [scala-cli](https://scala-cli.virtuslab.org), you can quickly start experimenting with sttp by copy-pasting the following: ``` -//> using dep "com.softwaremill.sttp.client4::core:4.0.0-M20" +//> using dep "com.softwaremill.sttp.client4::core:4.0.0-M21" import sttp.client4.quick._ quickRequest.get(uri"http://httpbin.org/ip").send() ``` @@ -71,7 +71,7 @@ The `quick` package import brings in the sttp API and a pre-configured, global s Similarly, using [Ammonite](http://ammonite.io): ```scala -import $ivy.`com.softwaremill.sttp.client4::core:4.0.0-M20` +import $ivy.`com.softwaremill.sttp.client4::core:4.0.0-M21` import sttp.client4.quick._ quickRequest.get(uri"http://httpbin.org/ip").send() ``` @@ -81,7 +81,7 @@ quickRequest.get(uri"http://httpbin.org/ip").send() Add the following dependency: ```scala -"com.softwaremill.sttp.client4" %% "core" % "4.0.0-M20" +"com.softwaremill.sttp.client4" %% "core" % "4.0.0-M21" ``` Then, import: @@ -138,7 +138,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 ThisBuild/version := "4.0.0-M20"`, before running `mdoc` in `docs`. +That is, in sbt run: `set ThisBuild/version := "4.0.0-M21"`, 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 05ef6466e..31f4ce0f4 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.client4" %% "akka-http-backend" % "4.0.0-M20" +"com.softwaremill.sttp.client4" %% "akka-http-backend" % "4.0.0-M21" ``` 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 3b9c83be1..4bf7ae1cf 100644 --- a/generated-docs/out/backends/catseffect.md +++ b/generated-docs/out/backends/catseffect.md @@ -14,7 +14,7 @@ Also note that the [http4s](http4s.md) backend can also be created for a type im Firstly, add the following dependency to your project: ```scala -"com.softwaremill.sttp.client4" %% "cats" % "4.0.0-M20" +"com.softwaremill.sttp.client4" %% "cats" % "4.0.0-M21" ``` Obtain a cats-effect `Resource` which creates the backend, and closes the thread pool after the resource is no longer used: @@ -82,9 +82,9 @@ Creation of the backend can be done in two basic ways: Firstly, add the following dependency to your project: ```scala -"com.softwaremill.sttp.client4" %% "armeria-backend-cats" % "4.0.0-M20" // for cats-effect 3.x +"com.softwaremill.sttp.client4" %% "armeria-backend-cats" % "4.0.0-M21" // for cats-effect 3.x // or -"com.softwaremill.sttp.client4" %% "armeria-backend-cats-ce2" % "4.0.0-M20" // for cats-effect 2.x +"com.softwaremill.sttp.client4" %% "armeria-backend-cats-ce2" % "4.0.0-M21" // for cats-effect 2.x ``` create client: diff --git a/generated-docs/out/backends/finagle.md b/generated-docs/out/backends/finagle.md index 1d316ff32..2e9cc78f7 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.client4" %% "finagle-backend" % "4.0.0-M20" +"com.softwaremill.sttp.client4" %% "finagle-backend" % "4.0.0-M21" ``` 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 e4b78b5c9..b28f7d212 100644 --- a/generated-docs/out/backends/fs2.md +++ b/generated-docs/out/backends/fs2.md @@ -12,9 +12,9 @@ Creation of the backend can be done in two basic ways: Firstly, add the following dependency to your project: ```scala -"com.softwaremill.sttp.client4" %% "fs2" % "4.0.0-M20" // for cats-effect 3.x & fs2 3.x +"com.softwaremill.sttp.client4" %% "fs2" % "4.0.0-M21" // for cats-effect 3.x & fs2 3.x // or -"com.softwaremill.sttp.client4" %% "fs2ce2" % "4.0.0-M20" // for cats-effect 2.x & fs2 2.x +"com.softwaremill.sttp.client4" %% "fs2ce2" % "4.0.0-M21" // 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: @@ -77,9 +77,9 @@ Host header override is supported in environments running Java 12 onwards, but i To use, add the following dependency to your project: ```scala -"com.softwaremill.sttp.client4" %% "armeria-backend-fs2" % "4.0.0-M20" // for cats-effect 3.x & fs2 3.x +"com.softwaremill.sttp.client4" %% "armeria-backend-fs2" % "4.0.0-M21" // for cats-effect 3.x & fs2 3.x // or -"com.softwaremill.sttp.client4" %% "armeria-backend-fs2" % "4.0.0-M20" // for cats-effect 2.x & fs2 2.x +"com.softwaremill.sttp.client4" %% "armeria-backend-fs2" % "4.0.0-M21" // for cats-effect 2.x & fs2 2.x ``` create client: diff --git a/generated-docs/out/backends/future.md b/generated-docs/out/backends/future.md index 86c7c44df..e99cc3715 100644 --- a/generated-docs/out/backends/future.md +++ b/generated-docs/out/backends/future.md @@ -21,7 +21,7 @@ Class Supported stream type To use, you don't need any extra dependencies, `core` is enough: ``` -"com.softwaremill.sttp.client4" %% "core" % "4.0.0-M20" +"com.softwaremill.sttp.client4" %% "core" % "4.0.0-M21" ``` You'll need the following imports: @@ -59,7 +59,7 @@ Host header override is supported in environments running Java 12 onwards, but i To use, add the following dependency to your project: ```scala -"com.softwaremill.sttp.client4" %% "okhttp-backend" % "4.0.0-M20" +"com.softwaremill.sttp.client4" %% "okhttp-backend" % "4.0.0-M21" ``` and some imports: @@ -91,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.client4" %% "armeria-backend" % "4.0.0-M20" +"com.softwaremill.sttp.client4" %% "armeria-backend" % "4.0.0-M21" ``` add imports: diff --git a/generated-docs/out/backends/http4s.md b/generated-docs/out/backends/http4s.md index da8c7c488..cabb67948 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.client4" %% "http4s-backend" % "4.0.0-M20" // for cats-effect 3.x & http4s 1.0.0-Mx +"com.softwaremill.sttp.client4" %% "http4s-backend" % "4.0.0-M21" // for cats-effect 3.x & http4s 1.0.0-Mx // or -"com.softwaremill.sttp.client4" %% "http4s-ce2-backend" % "4.0.0-M20" // for cats-effect 2.x & http4s 0.21.x +"com.softwaremill.sttp.client4" %% "http4s-ce2-backend" % "4.0.0-M21" // 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 da2ad1f52..71210917c 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.client4" %%% "core" % "4.0.0-M20" +"com.softwaremill.sttp.client4" %%% "core" % "4.0.0-M21" ``` 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.client4" %%% "monix" % "4.0.0-M20" +"com.softwaremill.sttp.client4" %%% "monix" % "4.0.0-M21" ``` And create the backend instance: @@ -40,7 +40,7 @@ val backend = FetchMonixBackend() To use, add the following dependency to your project: ``` -"com.softwaremill.sttp.client4" %%% "zio" % "4.0.0-M20" +"com.softwaremill.sttp.client4" %%% "zio" % "4.0.0-M21" ``` 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.client4" %%% "cats" % "4.0.0-M20" +"com.softwaremill.sttp.client4" %%% "cats" % "4.0.0-M21" ``` If you are on Cats Effect 2 (CE2) you will need to add the CE2 specific dependency instead: ``` -"com.softwaremill.sttp.client4" %%% "catsce2 % "4.0.0-M20" +"com.softwaremill.sttp.client4" %%% "catsce2 % "4.0.0-M21" ``` 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.client4" %%% "monix" % "4.0.0-M20" +"com.softwaremill.sttp.client4" %%% "monix" % "4.0.0-M21" ``` An example of streaming a response: diff --git a/generated-docs/out/backends/monix.md b/generated-docs/out/backends/monix.md index ef7efa360..4200f115f 100644 --- a/generated-docs/out/backends/monix.md +++ b/generated-docs/out/backends/monix.md @@ -12,7 +12,7 @@ Creation of the backend can be done in two basic ways: Firstly, add the following dependency to your project: ``` -"com.softwaremill.sttp.client4" %% "monix" % "4.0.0-M20" +"com.softwaremill.sttp.client4" %% "monix" % "4.0.0-M21" ``` and create the backend using: @@ -49,7 +49,7 @@ Host header override is supported in environments running Java 12 onwards, but i To use, add the following dependency to your project: ```scala -"com.softwaremill.sttp.client4" %% "okhttp-backend-monix" % "4.0.0-M20" +"com.softwaremill.sttp.client4" %% "okhttp-backend-monix" % "4.0.0-M21" ``` Create the backend using: @@ -75,7 +75,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.client4" %% "armeria-backend-monix" % "4.0.0-M20" +"com.softwaremill.sttp.client4" %% "armeria-backend-monix" % "4.0.0-M21" ``` add imports: diff --git a/generated-docs/out/backends/native/curl.md b/generated-docs/out/backends/native/curl.md index d9df8a792..69b42f8ee 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.client4" %%% "core" % "4.0.0-M20" +"com.softwaremill.sttp.client4" %%% "core" % "4.0.0-M21" ``` and initialize one of the backends: diff --git a/generated-docs/out/backends/pekko.md b/generated-docs/out/backends/pekko.md index 4441387d8..1c13ed962 100644 --- a/generated-docs/out/backends/pekko.md +++ b/generated-docs/out/backends/pekko.md @@ -3,7 +3,7 @@ This backend is based on [pekko-http](https://pekko.apache.org/docs/pekko-http/current/). To use, add the following dependency to your project: ``` -"com.softwaremill.sttp.client4" %% "pekko-http-backend" % "4.0.0-M20" +"com.softwaremill.sttp.client4" %% "pekko-http-backend" % "4.0.0-M21" ``` 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 Pekko. diff --git a/generated-docs/out/backends/scalaz.md b/generated-docs/out/backends/scalaz.md index 3962d7fef..7d8cf3b9e 100644 --- a/generated-docs/out/backends/scalaz.md +++ b/generated-docs/out/backends/scalaz.md @@ -8,7 +8,7 @@ The [Scalaz](https://github.com/scalaz/scalaz) backend is **asynchronous**. Send To use, add the following dependency to your project: ``` -"com.softwaremill.sttp.client4" %% "armeria-backend-scalaz" % "4.0.0-M20" +"com.softwaremill.sttp.client4" %% "armeria-backend-scalaz" % "4.0.0-M21" ``` add imports: diff --git a/generated-docs/out/backends/synchronous.md b/generated-docs/out/backends/synchronous.md index 6919912de..ab161946a 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.client4" %% "core" % "4.0.0-M20" +"com.softwaremill.sttp.client4" %% "core" % "4.0.0-M21" ``` 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.client4" %% "core" % "4.0.0-M20" +"com.softwaremill.sttp.client4" %% "core" % "4.0.0-M21" ``` 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.client4" %% "okhttp-backend" % "4.0.0-M20" +"com.softwaremill.sttp.client4" %% "okhttp-backend" % "4.0.0-M21" ``` Create the backend using: @@ -99,7 +99,7 @@ Both HttpClient and OkHttp backends support regular [websockets](../websockets.m ``` // sbt dependency -"com.softwaremill.sttp.client4" %% "ox" % "4.0.0-M20", +"com.softwaremill.sttp.client4" %% "ox" % "4.0.0-M21", ``` ```scala diff --git a/generated-docs/out/backends/wrappers/custom.md b/generated-docs/out/backends/wrappers/custom.md index 6addf5364..0dc9751c5 100644 --- a/generated-docs/out/backends/wrappers/custom.md +++ b/generated-docs/out/backends/wrappers/custom.md @@ -237,7 +237,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.client4" %% "core" % "4.0.0-M20" % Test classifier "tests" +"com.softwaremill.sttp.client4" %% "core" % "4.0.0-M21" % Test classifier "tests" ``` Implement your backend and extend the `HttpTest` class: @@ -264,9 +264,9 @@ import sttp.client4.impl.cats.implicits._ from the cats integration module. The module should be available on the classpath after adding following dependency: ```scala -"com.softwaremill.sttp.client4" %% "cats" % "4.0.0-M20" // for cats-effect 3.x +"com.softwaremill.sttp.client4" %% "cats" % "4.0.0-M21" // for cats-effect 3.x // or -"com.softwaremill.sttp.client4" %% "catsce2" % "4.0.0-M20" // for cats-effect 2.x +"com.softwaremill.sttp.client4" %% "catsce2" % "4.0.0-M21" // for cats-effect 2.x ``` The object contains implicits to convert a cats `MonadError` into the sttp `MonadError`, diff --git a/generated-docs/out/backends/wrappers/logging.md b/generated-docs/out/backends/wrappers/logging.md index b8b3748fa..fa6b826b2 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.client4" %% "slf4j-backend" % "4.0.0-M20" +"com.softwaremill.sttp.client4" %% "slf4j-backend" % "4.0.0-M21" ``` 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.x/log4j-slf4j-impl.html). @@ -53,5 +53,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.client4" %% "scribe-backend" % "4.0.0-M20" +"com.softwaremill.sttp.client4" %% "scribe-backend" % "4.0.0-M21" ``` \ 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 7f2b5c056..bc2bd7639 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.client4" %% "opentelemetry-metrics-backend" % "4.0.0-M20" +"com.softwaremill.sttp.client4" %% "opentelemetry-metrics-backend" % "4.0.0-M21" ``` Then an instance can be obtained as follows: @@ -55,7 +55,7 @@ OpenTelemetryMetricsBackend( To use, add the following dependency to your project: ``` -"com.softwaremill.sttp.client4" %% "opentelemetry-tracing-zio-backend" % "4.0.0-M20" // for ZIO 2.x +"com.softwaremill.sttp.client4" %% "opentelemetry-tracing-zio-backend" % "4.0.0-M21" // for ZIO 2.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 939fa07d7..8721eb8f9 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.client4" %% "prometheus-backend" % "4.0.0-M20" +"com.softwaremill.sttp.client4" %% "prometheus-backend" % "4.0.0-M21" ``` and some imports: diff --git a/generated-docs/out/backends/zio.md b/generated-docs/out/backends/zio.md index bbfea8140..a482ca22d 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.client4" %% "zio" % "4.0.0-M20" // for ZIO 2.x -"com.softwaremill.sttp.client4" %% "zio1" % "4.0.0-M20" // for ZIO 1.x +"com.softwaremill.sttp.client4" %% "zio" % "4.0.0-M21" // for ZIO 2.x +"com.softwaremill.sttp.client4" %% "zio1" % "4.0.0-M21" // for ZIO 1.x ``` Create the backend using: @@ -45,8 +45,8 @@ Host header override is supported in environments running Java 12 onwards, but i To use, add the following dependency to your project: ``` -"com.softwaremill.sttp.client4" %% "armeria-backend-zio" % "4.0.0-M20" // for ZIO 2.x -"com.softwaremill.sttp.client4" %% "armeria-backend-zio1" % "4.0.0-M20" // for ZIO 1.x +"com.softwaremill.sttp.client4" %% "armeria-backend-zio" % "4.0.0-M21" // for ZIO 2.x +"com.softwaremill.sttp.client4" %% "armeria-backend-zio1" % "4.0.0-M21" // for ZIO 1.x ``` add imports: diff --git a/generated-docs/out/includes/examples_list.md b/generated-docs/out/includes/examples_list.md index 6d7213f9c..2d40537dd 100644 --- a/generated-docs/out/includes/examples_list.md +++ b/generated-docs/out/includes/examples_list.md @@ -1,6 +1,6 @@ ## Hello, World! -* [POST JSON data](https://github.com/softwaremill/sttp/tree/master/examples-ce2/src/main/scala/sttp/client4/examples/PostSerializeJsonMonixHttpClientCirce.scala) HttpClient Monix +* [Post JSON data](https://github.com/softwaremill/sttp/tree/master/examples-ce2/src/main/scala/sttp/client4/examples/PostSerializeJsonMonixHttpClientCirce.scala) HttpClient Monix * [Post form data](https://github.com/softwaremill/sttp/tree/master/examples/src/main/scala/sttp/client4/examples/PostFormSynchronous.scala) HttpClient Direct ## JSON @@ -28,12 +28,12 @@ ## Testing -* [Create a backend stub which simulates interactions using multiple query parameters](https://github.com/softwaremill/sttp/tree/master/examples/src/main/scala/sttp/client4/examples/testEndpointMultipleQueryParameters.scala) +* [Create a backend stub which simulates interactions using multiple query parameters](https://github.com/softwaremill/sttp/tree/master/examples/src/main/scala/sttp/client4/examples/TestEndpointMultipleQueryParameters.scala) * [Create a backend stub which simulates interactions with a WebSocket](https://github.com/softwaremill/sttp/tree/master/examples/src/main/scala/sttp/client4/examples/WebSocketTesting.scala) HttpClient cats-effect ## WebSocket -* [Connect to & interact with a WebSocket](https://github.com/softwaremill/sttp/tree/master/examples/src/main/scala/sttp/client4/examples/webSocketPekko.scala) Pekko Future +* [Connect to & interact with a WebSocket](https://github.com/softwaremill/sttp/tree/master/examples/src/main/scala/sttp/client4/examples/WebSocketPekko.scala) Pekko Future * [Connect to & interact with a WebSocket](https://github.com/softwaremill/sttp/tree/master/examples/src/main/scala/sttp/client4/examples/WebSocketZio.scala) HttpClient ZIO * [Connect to & interact with a WebSocket](https://github.com/softwaremill/sttp/tree/master/examples/src/main/scala/sttp/client4/examples/WebSocketSynchronous.scala) HttpClient Direct * [Connect to & interact with a WebSocket](https://github.com/softwaremill/sttp/tree/master/examples-ce2/src/main/scala/sttp/client4/examples/WebSocketMonix.scala) HttpClient Monix diff --git a/generated-docs/out/index.md b/generated-docs/out/index.md index eb5b1eb5f..7668f7973 100644 --- a/generated-docs/out/index.md +++ b/generated-docs/out/index.md @@ -9,28 +9,29 @@ requests and how to handle responses. Requests are sent using one of the backend Backend implementations include the HTTP client that is shipped with Java, as well as ones based on [akka-http](https://doc.akka.io/docs/akka-http/current/scala/http/), [pekko-http](https://pekko.apache.org/docs/pekko-http/current/), [http4s](https://http4s.org), [OkHttp](http://square.github.io/okhttp/). 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.12, 2.13 and 3, Scala.JS and Scala Native; supported Java versions include 11+. -Here's a quick example of sttp client in action: +Here's a quick example of sttp client in action, runnable using [scala-cli](https://scala-cli.virtuslab.org): ```scala +//> using dep com.softwaremill.sttp.client4::core:4.0.0-M20 + import sttp.client4.* -val query = "http language:scala" -val sort: Option[String] = None +@main def sttpDemo(): Unit = + val sort: Option[String] = None + val query = "http language:scala" -// the `query` parameter is automatically url-encoded -// `sort` is removed, as the value is not defined -val request = basicRequest.get( - uri"https://api.github.com/search/repositories?q=$query&sort=$sort") + // the `query` parameter is automatically url-encoded + // `sort` is removed, as the value is not defined + val request = basicRequest.get(uri"https://api.github.com/search/repositories?q=$query&sort=$sort") -val backend = DefaultSyncBackend() -val response = request.send(backend) + val backend = DefaultSyncBackend() + val response = request.send(backend) -// response.header(...): Option[String] -println(response.header("Content-Length")) + // response.header(...): Option[String] + println(response.header("Content-Length")) -// response.body: by default read into an Either[String, String] -// to indicate failure or success -println(response.body) + // response.body: by default read into an Either[String, String] to indicate failure or success + println(response.body) ``` For more examples, see the [usage examples](examples.md) section. To start using sttp client in your project, see the [quickstart](quickstart.md). Or, browse the documentation to find the topics that interest you the most! ScalaDoc is available at [https://www.javadoc.io](https://www.javadoc.io/doc/com.softwaremill.sttp.client4/core_2.12/4.0.0-M9). diff --git a/generated-docs/out/json.md b/generated-docs/out/json.md index 3c05bdd7f..383595b86 100644 --- a/generated-docs/out/json.md +++ b/generated-docs/out/json.md @@ -43,7 +43,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.client4" %% "circe" % "4.0.0-M20" +"com.softwaremill.sttp.client4" %% "circe" % "4.0.0-M21" ``` 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. @@ -75,7 +75,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.client4" %% "json4s" % "4.0.0-M20" +"com.softwaremill.sttp.client4" %% "json4s" % "4.0.0-M21" "org.json4s" %% "json4s-native" % "3.6.0" ``` @@ -111,7 +111,7 @@ val response: Response[Either[ResponseException[String, Exception], ResponsePayl To encode and decode JSON using [spray-json](https://github.com/spray/spray-json), add the following dependency to your project: ``` -"com.softwaremill.sttp.client4" %% "spray-json" % "4.0.0-M20" +"com.softwaremill.sttp.client4" %% "spray-json" % "4.0.0-M21" ``` 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`. @@ -143,13 +143,13 @@ val response: Response[Either[ResponseException[String, Exception], ResponsePayl To encode and decode JSON using [play-json](https://www.playframework.com), add the following dependency to your project: ```scala -"com.softwaremill.sttp.client4" %% "play-json" % "4.0.0-M20" +"com.softwaremill.sttp.client4" %% "play-json" % "4.0.0-M21" ``` If you use older version of play (2.9.x), add the following dependency to your project: ```scala -"com.softwaremill.sttp.client4" %% "play29-json" % "4.0.0-M20" +"com.softwaremill.sttp.client4" %% "play29-json" % "4.0.0-M21" ``` To use, add an import: `import sttp.client4.playJson._`. @@ -161,13 +161,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.client4" %% "zio-json" % "4.0.0-M20" // for ZIO 2.x -"com.softwaremill.sttp.client4" %% "zio1-json" % "4.0.0-M20" // for ZIO 1.x +"com.softwaremill.sttp.client4" %% "zio-json" % "4.0.0-M21" // for ZIO 2.x +"com.softwaremill.sttp.client4" %% "zio1-json" % "4.0.0-M21" // for ZIO 1.x ``` or for ScalaJS (cross build) projects: ```scala -"com.softwaremill.sttp.client4" %%% "zio-json" % "4.0.0-M20" // for ZIO 2.x -"com.softwaremill.sttp.client4" %%% "zio1-json" % "4.0.0-M20" // for ZIO 1.x +"com.softwaremill.sttp.client4" %%% "zio-json" % "4.0.0-M21" // for ZIO 2.x +"com.softwaremill.sttp.client4" %%% "zio1-json" % "4.0.0-M21" // for ZIO 1.x ``` To use, add an import: `import sttp.client4.ziojson._` (or extend `SttpZioJsonApi`), define an implicit `JsonCodec`, or `JsonDecoder`/`JsonEncoder` for your datatype. @@ -199,13 +199,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.client4" %% "jsoniter" % "4.0.0-M20" +"com.softwaremill.sttp.client4" %% "jsoniter" % "4.0.0-M21" ``` or for ScalaJS (cross build) projects: ```scala -"com.softwaremill.sttp.client4" %%% "jsoniter" % "4.0.0-M20" +"com.softwaremill.sttp.client4" %%% "jsoniter" % "4.0.0-M21" ``` To use, add an import: `import sttp.client4.jsoniter._` (or extend `SttpJsonIterJsonApi`), define an implicit `JsonCodec`, or `JsonDecoder`/`JsonEncoder` for your datatype. @@ -239,13 +239,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.client4" %% "upickle" % "4.0.0-M20" +"com.softwaremill.sttp.client4" %% "upickle" % "4.0.0-M21" ``` or for ScalaJS (cross build) projects: ```scala -"com.softwaremill.sttp.client4" %%% "upickle" % "4.0.0-M20" +"com.softwaremill.sttp.client4" %%% "upickle" % "4.0.0-M21" ``` To use, add an import: `import sttp.client4.upicklejson.default._` 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 62917b525..f625efcb1 100644 --- a/generated-docs/out/openapi.md +++ b/generated-docs/out/openapi.md @@ -43,8 +43,8 @@ lazy val petstoreApi: Project = project openApiGeneratorName := "scala-sttp", openApiOutputDir := baseDirectory.value.name, libraryDependencies ++= Seq( - "com.softwaremill.sttp.client4" %% "core" % "4.0.0-M20", - "com.softwaremill.sttp.client4" %% "json4s" % "4.0.0-M20", + "com.softwaremill.sttp.client4" %% "core" % "4.0.0-M21", + "com.softwaremill.sttp.client4" %% "json4s" % "4.0.0-M21", "org.json4s" %% "json4s-jackson" % "3.6.8" ) ) @@ -94,8 +94,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.client4" %% "core" % "4.0.0-M20", - "com.softwaremill.sttp.client4" %% "json4s" % "4.0.0-M20", + "com.softwaremill.sttp.client4" %% "core" % "4.0.0-M21", + "com.softwaremill.sttp.client4" %% "json4s" % "4.0.0-M21", "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 f0a578217..009afabf5 100644 --- a/generated-docs/out/quickstart.md +++ b/generated-docs/out/quickstart.md @@ -15,7 +15,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.client4" %% "core" % "4.0.0-M20" +"com.softwaremill.sttp.client4" %% "core" % "4.0.0-M21" ``` ## Using scala-cli @@ -23,7 +23,7 @@ The basic dependency which provides the API, together with a synchronous and `Fu Add the following directive to the top of your scala file to add the core sttp dependency: ``` -//> using dep "com.softwaremill.sttp.client4::core:4.0.0-M20" +//> using dep "com.softwaremill.sttp.client4::core:4.0.0-M21" ``` ## Using Ammonite @@ -31,7 +31,7 @@ Add the following directive to the top of your scala file to add the core sttp d 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.client4::core:4.0.0-M20` +import $ivy.`com.softwaremill.sttp.client4::core:4.0.0-M21` ``` ## Imports @@ -72,7 +72,7 @@ As an example, to integrate with the [uPickle](https://github.com/com-lihaoyi/up dependency: ```scala -"com.softwaremill.sttp.client4" %% "upickle" % "4.0.0-M20" +"com.softwaremill.sttp.client4" %% "upickle" % "4.0.0-M21" ``` Your code might then look as follows: @@ -109,7 +109,7 @@ Logging can be added using the [logging backend wrapper](backends/wrappers/loggi use slf4j, you'll need the following dependency: ``` -"com.softwaremill.sttp.client4" %% "slf4j-backend" % "4.0.0-M20" +"com.softwaremill.sttp.client4" %% "slf4j-backend" % "4.0.0-M21" ``` Then, you'll need to configure your client: diff --git a/generated-docs/out/requests/body.md b/generated-docs/out/requests/body.md index 6e32bce21..b170b4b2e 100644 --- a/generated-docs/out/requests/body.md +++ b/generated-docs/out/requests/body.md @@ -106,3 +106,13 @@ basicRequest.body(serializePerson(Person("mary", "smith", 67))) ``` See the implementations of the `BasicBody` trait for more options. + +## Compressing bodies + +Request bodies can be compressed, using an algorithm that's supported by the backend. By default, all backends support the `gzip` and `deflate` compression algorithms. + +To compress a request body, use the `request.compressBody(encoding)` method. This will set the the `Content-Encoding` header on the request, as well as compress the body when the request is sent. If the given encoding is not supported by the backend, an exception will be thrown / a failed effect will be returned. + +Support for custom compression algorithms can be added at backend creation time, by customising the `compressionHandlers` parameter, and adding a `Compressor` implementation. Such an implementation has to specify the encoding, which it handles, as well as appropriate body transformation (which is backend-specific). + +Note that clients often don't know upfront which compression algorithms (if at all) the server supports, and that's why requests are often sent uncompressed. Sending an encoded (compressed) body, when the server doesn't support decompression, might lead to 4xx or 5xx errors. \ No newline at end of file diff --git a/generated-docs/out/responses/body.md b/generated-docs/out/responses/body.md index dc93c85f8..b0a68bb09 100644 --- a/generated-docs/out/responses/body.md +++ b/generated-docs/out/responses/body.md @@ -245,3 +245,14 @@ val response: Future[Response[Either[String, Source[ByteString, Any]]]] = ``` It's also possible to parse the received stream as server-sent events (SSE), using an implementation-specific mapping function. Refer to the documentation for particular backends for more details. + +## Decompressing bodies (handling the Conent-Encoding header) + +If the response body is compressed using `gzip` or `deflate` algorithms, it will be decompressed if the `decompressResponseBody` request option is set. By default this is set to `true`, and can be disabled using the `request.disableAutoDecompression` method. + +The encoding of the response body is determined by the encodings that are accepted by the client. That's why `basicRequest` and `quickRequest` both have the `Accept-Encoding` header set to `gzip, deflate`. That's in contrast to `emptyRequest`, which has no headers set by default. + +If you'd like to use additional decompression algorithms, you'll need to: + +* amend the `Accept-Encoding` header that's set on the request +* add a decompression algorithm to the backend; that can be done on backend creation time, by customising the `compressionHandlers` parameter, and adding a `Decompressor` implementation. Such an implementation has to specify the encoding, which it handles, as well as appropriate body transformation (which is backend-specific). \ No newline at end of file diff --git a/generated-docs/out/websockets.md b/generated-docs/out/websockets.md index 0a66e815c..755fcab59 100644 --- a/generated-docs/out/websockets.md +++ b/generated-docs/out/websockets.md @@ -104,7 +104,7 @@ as Ox `Source` and `Sink`: ``` // sbt dependency -"com.softwaremill.sttp.client4" %% "ox" % "4.0.0-M20", +"com.softwaremill.sttp.client4" %% "ox" % "4.0.0-M21", ``` ```scala