Skip to content

Commit

Permalink
Release 3.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Pask committed May 6, 2022
1 parent e76a46e commit 9d36511
Show file tree
Hide file tree
Showing 35 changed files with 358 additions and 500 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.5.2)
scaladoc is available at [https://www.javadoc.io](https://www.javadoc.io/doc/com.softwaremill.sttp.client3/core_2.12/3.6.0)

## 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.5.2`
import $ivy.`com.softwaremill.sttp.client3::core:3.6.0`
import sttp.client3.quick._
quickRequest.get(uri"http://httpbin.org/ip").send(backend)
```
Expand All @@ -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.5.2"
"com.softwaremill.sttp.client3" %% "core" % "3.6.0"
```

Then, import:
Expand Down Expand Up @@ -98,7 +98,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.5.2"`, before running `mdoc` in `docs`.
That is, in sbt run: `set version := "3.6.0"`, before running `mdoc` in `docs`.

### Testing the Scala.JS backend

Expand Down
2 changes: 1 addition & 1 deletion generated-docs/out/backends/akka.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.5.2"
"com.softwaremill.sttp.client3" %% "akka-http-backend" % "3.6.0"
```

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.
Expand Down
8 changes: 4 additions & 4 deletions generated-docs/out/backends/catseffect.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ Note that all [fs2](fs2.md) backends also support any cats-effect effect, additi
To use, add the following dependency to your project:

```scala
"com.softwaremill.sttp.client3" %% "async-http-client-backend-cats" % "3.5.2" // for cats-effect 3.x
"com.softwaremill.sttp.client3" %% "async-http-client-backend-cats" % "3.6.0" // for cats-effect 3.x
// or
"com.softwaremill.sttp.client3" %% "async-http-client-backend-cats-ce2" % "3.5.2" // for cats-effect 2.x
"com.softwaremill.sttp.client3" %% "async-http-client-backend-cats-ce2" % "3.6.0" // 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.
Expand Down Expand Up @@ -83,9 +83,9 @@ val backend = AsyncHttpClientCatsBackend.usingClient[IO](asyncHttpClient)
To use, add the following dependency to your project:

```scala
"com.softwaremill.sttp.client3" %% "armeria-backend-cats" % "3.5.2" // for cats-effect 3.x
"com.softwaremill.sttp.client3" %% "armeria-backend-cats" % "3.6.0" // for cats-effect 3.x
// or
"com.softwaremill.sttp.client3" %% "armeria-backend-cats-ce2" % "3.5.2" // for cats-effect 2.x
"com.softwaremill.sttp.client3" %% "armeria-backend-cats-ce2" % "3.6.0" // for cats-effect 2.x
```

create client:
Expand Down
2 changes: 1 addition & 1 deletion generated-docs/out/backends/finagle.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
To use, add the following dependency to your project:

```
"com.softwaremill.sttp.client3" %% "finagle-backend" % "3.5.2"
"com.softwaremill.sttp.client3" %% "finagle-backend" % "3.6.0"
```

Next you'll need to add an implicit value:
Expand Down
119 changes: 60 additions & 59 deletions generated-docs/out/backends/fs2.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,68 @@
# fs2 backend

The [fs2](https://github.com/functional-streams-for-scala/fs2) backend is **asynchronous**. It can be created for any type implementing the `cats.effect.Async` 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 [fs2](https://github.com/functional-streams-for-scala/fs2) backends are **asynchronous**. They can be created for any type implementing the `cats.effect.Async` 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`.

## Using HttpClient

To use, add the following dependency to your project:

```scala
"com.softwaremill.sttp.client3" %% "fs2" % "3.6.0" // for cats-effect 3.x & fs2 3.x
// or
"com.softwaremill.sttp.client3" %% "fs2-ce2" % "3.6.0" // 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:

```scala
import cats.effect.IO
import sttp.client3.httpclient.fs2.HttpClientFs2Backend

HttpClientFs2Backend.resource[IO]().use { backend => ??? }
```

or, by providing a custom `Dispatcher`:

```scala
import cats.effect.IO
import cats.effect.std.Dispatcher
import sttp.client3.httpclient.fs2.HttpClientFs2Backend

val dispatcher: Dispatcher[IO] = ???

HttpClientFs2Backend[IO](dispatcher).flatMap { backend => ??? }
```

or, if you'd like to instantiate the `HttpClient` yourself:

```scala
import cats.effect.IO
import cats.effect.std.Dispatcher
import java.net.http.HttpClient
import sttp.client3.httpclient.fs2.HttpClientFs2Backend

val httpClient: HttpClient = ???
val dispatcher: Dispatcher[IO] = ???

val backend = HttpClientFs2Backend.usingClient[IO](httpClient, dispatcher)
```

This backend is based on the built-in `java.net.http.HttpClient` available from Java 11 onwards.

Host header override is supported in environments running Java 12 onwards, but it has to be enabled by system property:

```
-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.5.2" // for cats-effect 3.x & fs2 3.x
"com.softwaremill.sttp.client3" %% "async-http-client-backend-fs2" % "3.6.0" // for cats-effect 3.x & fs2 3.x
// or
"com.softwaremill.sttp.client3" %% "async-http-client-backend-fs2-ce2" % "3.5.2" // for cats-effect 2.x & fs2 2.x
"com.softwaremill.sttp.client3" %% "async-http-client-backend-fs2-ce2" % "3.6.0" // 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.
Expand Down Expand Up @@ -83,66 +136,14 @@ val asyncHttpClient: AsyncHttpClient = ???
val backend = AsyncHttpClientFs2Backend.usingClient[IO](asyncHttpClient, dispatcher)
```

## Using HttpClient (Java 11+)

To use, add the following dependency to your project:

```scala
"com.softwaremill.sttp.client3" %% "httpclient-backend-fs2" % "3.5.2" // for cats-effect 3.x & fs2 3.x
// or
"com.softwaremill.sttp.client3" %% "httpclient-backend-fs2-ce2" % "3.5.2" // for cats-effect 2.x & fs2 2.x
```

Create the backend using a cats-effect `Resource`:

```scala
import cats.effect.IO
import sttp.client3.httpclient.fs2.HttpClientFs2Backend

HttpClientFs2Backend.resource[IO]().use { backend => ??? }
```

or, if by providing a custom `Dispatcher`:

```scala
import cats.effect.IO
import cats.effect.std.Dispatcher
import sttp.client3.httpclient.fs2.HttpClientFs2Backend

val dispatcher: Dispatcher[IO] = ???

HttpClientFs2Backend[IO](dispatcher).flatMap { backend => ??? }
```

or, if you'd like to instantiate the `HttpClient` yourself:

```scala
import cats.effect.IO
import cats.effect.std.Dispatcher
import java.net.http.HttpClient
import sttp.client3.httpclient.fs2.HttpClientFs2Backend

val httpClient: HttpClient = ???
val dispatcher: Dispatcher[IO] = ???

val backend = HttpClientFs2Backend.usingClient[IO](httpClient, dispatcher)
```

This backend is based on the built-in `java.net.http.HttpClient` available from Java 11 onwards.

Host header override is supported in environments running Java 12 onwards, but it has to be enabled by system property:
```
jdk.httpclient.allowRestrictedHeaders=host
```

## Using Armeria

To use, add the following dependency to your project:

```scala
"com.softwaremill.sttp.client3" %% "armeria-backend-fs2" % "3.5.2" // for cats-effect 3.x & fs2 3.x
"com.softwaremill.sttp.client3" %% "armeria-backend-fs2" % "3.6.0" // for cats-effect 3.x & fs2 3.x
// or
"com.softwaremill.sttp.client3" %% "armeria-backend-fs2" % "3.5.2" // for cats-effect 2.x & fs2 2.x
"com.softwaremill.sttp.client3" %% "armeria-backend-fs2" % "3.6.0" // for cats-effect 2.x & fs2 2.x
```

create client:
Expand Down Expand Up @@ -190,7 +191,7 @@ Please visit [the official documentation](https://armeria.dev/docs/client-factor

## Streaming

The fs2 backend supports streaming for any instance of the `cats.effect.Effect` typeclass, such as `cats.effect.IO`. If `IO` is used then the type of supported streams is `fs2.Stream[IO, Byte]`. The streams capability is represented as `sttp.client3.fs2.Fs2Streams`.
The fs2 backends support streaming for any instance of the `cats.effect.Effect` typeclass, such as `cats.effect.IO`. If `IO` is used then the type of supported streams is `fs2.Stream[IO, Byte]`. The streams capability is represented as `sttp.client3.fs2.Fs2Streams`.

Requests can be sent with a streaming body like this:

Expand Down Expand Up @@ -236,7 +237,7 @@ val effect = AsyncHttpClientFs2Backend.resource[IO]().use { backend =>

## Websockets

The fs2 backend supports both regular and streaming [websockets](../websockets.md).
The fs2 backends support both regular and streaming [websockets](../websockets.md).

## Server-sent events

Expand Down
83 changes: 42 additions & 41 deletions generated-docs/out/backends/future.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,58 @@ Apart from the ones described below, also the [Akka](akka.md) backend is `Future
===================================== ================================================ ==========================
Class Supported stream type Websocket support
===================================== ================================================ ==========================
``HttpClientFutureBackend`` n/a yes (regular)
``AkkaHttpBackend`` ``akka.stream.scaladsl.Source[ByteString, Any]`` yes (regular & streaming)
``AsyncHttpClientFutureBackend`` n/a no
``OkHttpFutureBackend`` n/a yes (regular)
``HttpClientFutureBackend`` (Java11+) n/a yes (regular)
``ArmeriaFutureBackend`` n/a n/a
===================================== ================================================ ==========================
```

## Using HttpClient

To use, you don't need any extra dependencies, `core` is enough:

```
"com.softwaremill.sttp.client3" %% "core" % "3.6.0"
```

You'll need the following imports:

```scala
import sttp.client3.HttpClientFutureBackend
import scala.concurrent.ExecutionContext.Implicits.global
```

Create the backend using:

```scala
val backend = HttpClientFutureBackend()
```

or, if you'd like to instantiate the HttpClient yourself:

```scala
import java.net.http.HttpClient

val client: HttpClient = ???
val backend = HttpClientFutureBackend.usingClient(client)
```

This backend is based on the built-in `java.net.http.HttpClient` available from Java 11 onwards.

Host header override is supported in environments running Java 12 onwards, but it has to be enabled by system property:

```
-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.5.2"
"com.softwaremill.sttp.client3" %% "async-http-client-backend-future" % "3.6.0"
```

And some imports:
Expand Down Expand Up @@ -72,7 +110,7 @@ val backend = AsyncHttpClientFutureBackend.usingClient(asyncHttpClient)
To use, add the following dependency to your project:

```scala
"com.softwaremill.sttp.client3" %% "okhttp-backend" % "3.5.2"
"com.softwaremill.sttp.client3" %% "okhttp-backend" % "3.6.0"
```

and some imports:
Expand All @@ -99,49 +137,12 @@ val backend = OkHttpFutureBackend.usingClient(asyncHttpClient)

This backend depends on [OkHttp](http://square.github.io/okhttp/) and fully supports HTTP/2.

## Using HttpClient (Java 11+)

To use, add the following dependency to your project:

```
"com.softwaremill.sttp.client3" %% "httpclient-backend" % "3.5.2"
```

and some imports:

```scala
import sttp.client3.httpclient.HttpClientFutureBackend
import scala.concurrent.ExecutionContext.Implicits.global
```

Create the backend using:

```scala
val backend = HttpClientFutureBackend()
```

or, if you'd like to instantiate the HttpClient yourself:

```scala
import java.net.http.HttpClient

val client: HttpClient = ???
val backend = HttpClientFutureBackend.usingClient(client)
```

This backend is based on the built-in `java.net.http.HttpClient` available from Java 11 onwards, works with all Scala versions. A Scala 3 build is available as well.

Host header override is supported in environments running Java 12 onwards, but it has to be enabled by system property:
```
jdk.httpclient.allowRestrictedHeaders=host
```

## Using Armeria

To use, add the following dependency to your project:

```
"com.softwaremill.sttp.client3" %% "armeria-backend" % "3.5.2"
"com.softwaremill.sttp.client3" %% "armeria-backend" % "3.6.0"
```

add imports:
Expand Down
4 changes: 2 additions & 2 deletions generated-docs/out/backends/http4s.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.5.2" // for cats-effect 3.x & http4s 1.0.0-Mx
"com.softwaremill.sttp.client3" %% "http4s-backend" % "3.6.0" // for cats-effect 3.x & http4s 1.0.0-Mx
// or
"com.softwaremill.sttp.client3" %% "http4s-ce2-backend" % "3.5.2" // for cats-effect 2.x & http4s 0.21.x
"com.softwaremill.sttp.client3" %% "http4s-ce2-backend" % "3.6.0" // for cats-effect 2.x & http4s 0.21.x
```

The backend can be created in a couple of ways, e.g.:
Expand Down
Loading

0 comments on commit 9d36511

Please sign in to comment.