sttp

The Scala HTTP client you always wanted!

APACHE-2.0 License

Stars
1.4K

Bot releases are hidden (Show)

sttp - v3.0.0-RC5

Published by adamw about 4 years ago

This is a preview release, containing most of the functionality planned for sttp v3. The code passes all tests, however the API might change.

sttp client v3 uses a new package name (sttp.client3) and organization (com.softwaremill.sttp.client3). This way old and new sttp client versions can be used side-by-side. Make sure to update your imports and build dependencies!

Documentation is updated for the new version.

Breaking changes since v2:

SttpBackend trait

The trait now has 2, instead of 3 parameters. The "default" case of a backend with no additional capabilities changed:

SttpBackend[F, Nothing, NothingT] --> SttpBackend[F, Any]

The second type parameter now contains a list of supported additional capabilities. This can include:

  • an implementation of Streams
  • WebSockets

Finally, the type of supported streams is not given directly, but wrapped in a Streams object. For example, the types of the AkkaHttpBackend and AsyncHttpClientZioBackend backends now are:

SttpBackend[Future, AkkaStreams with WebSockets]
SttpBackend[Task, ZioStreams with WebSockets]

Request type

The type describing a request has undergone similar changes, with the last type parameter specifying the requirements that a backend must meet in order of the request to be sent. The "default" description of a request which doesn't use websockets or streams changed:

Request[T, Nothing] -> Request[T, Any]

Similarly, the type of ResponseAs changed.

The Request.send() method, which used an implicit SttpBackend is deprecated. Instead, use Request.send(backend), giving the backend explicitly.

SttpBackendStub

  • method name change: thenRespondWrapped -> thenRespondF
  • when nothing is stubbed, an exception (failed effect) is thrown, instead of returning 404

Other

  • ResponseError -> ResponseException, but type aliases are provided
  • ResponseException is parametrised with library-specific deserialisation exception type and http-error type. What previous was ResponseError[E] now would be ResponseException[String, E]
  • streamBody sets application/octet-stream as the content type by default
  • the default execution context used in the akka-http backend is different: instead of global, the EC backing the provided actor system is used
  • for zio backends, the send method has been moved from SttpClient to the package (for consistency with other zio libraries)
  • logging backends have been combined into a single one, exposing various configuration options
sttp - v3.0.0-RC4

Published by adamw about 4 years ago

This is a preview release, containing most of the functionality planned for sttp v3. The code passes all tests, however the API might change.

sttp client v3 uses a new package name (sttp.client3) and organization (com.softwaremill.sttp.client3). This way old and new sttp client versions can be used side-by-side. Make sure to update your imports and build dependencies!

Breaking changes since v2:

SttpBackend trait

The trait now has 2, instead of 3 parameters. The "default" case of a backend with no additional capabilities changed:

SttpBackend[F, Nothing, NothingT] --> SttpBackend[F, Any]

The second type parameter now contains a list of supported additional capabilities. This can include:

  • an implementation of Streams
  • WebSockets

Finally, the type of supported streams is not given directly, but wrapped in a Streams object. For example, the types of the AkkaHttpBackend and AsyncHttpClientZioBackend backends now are:

SttpBackend[Future, AkkaStreams with WebSockets]
SttpBackend[Task, ZioStreams with WebSockets]

Request type

The type describing a request has undergone similar changes, with the last type parameter specifying the requirements that a backend must meet in order of the request to be sent. The "default" description of a request which doesn't use websockets or streams changed:

Request[T, Nothing] -> Request[T, Any]

Similarly, the type of ResponseAs changed.

The Request.send() method, which used an implicit SttpBackend is deprecated. Instead, use Request.send(backend), giving the backend explicitly.

SttpBackendStub

  • method name change: thenRespondWrapped -> thenRespondF
  • when nothing is stubbed, an exception (failed effect) is thrown, instead of returning 404

Other

  • ResponseError -> ResponseException, but type aliases are provided
  • ResponseException is parametrised with library-specific deserialisation exception type and http-error type. What previous was ResponseError[E] now would be ResponseException[String, E]
  • streamBody sets application/octet-stream as the content type by default
  • the default execution context used in the akka-http backend is different: instead of global, the EC backing the provided actor system is used
  • for zio backends, the send method has been moved from SttpClient to the package (for consistency with other zio libraries)
  • logging backends have been combined into a single one, exposing various configuration options
sttp - v3.0.0-RC3

Published by adamw about 4 years ago

This is a preview release, containing most of the functionality planned for sttp v3. The code passes all tests, however the API might change.

Breaking changes since v2:

SttpBackend trait

The trait now has 2, instead of 3 parameters. The "default" case of a backend with no additional capabilities changed:

SttpBackend[F, Nothing, NothingT] --> SttpBackend[F, Any]

The second type parameter now contains a list of supported additional capabilities. This can include:

  • an implementation of Streams
  • WebSockets

Finally, the type of supported streams is not given directly, but wrapped in a Streams object. For example, the types of the AkkaHttpBackend and AsyncHttpClientZioBackend backends now are:

SttpBackend[Future, AkkaStreams with WebSockets]
SttpBackend[Task, ZioStreams with WebSockets]

Request type

The type describing a request has undergone similar changes, with the last type parameter specifying the requirements that a backend must meet in order of the request to be sent. The "default" description of a request which doesn't use websockets or streams changed:

Request[T, Nothing] -> Request[T, Any]

Similarly, the type of ResponseAs changed.

The Request.send() method, which used an implicit SttpBackend is deprecated. Instead, use Request.send(backend), giving the backend explicitly.

SttpBackendStub

  • method name change: thenRespondWrapped -> thenRespondF
  • when nothing is stubbed, an exception (failed effect) is thrown, instead of returning 404

Other

  • ResponseError -> ResponseException, but type aliases are provided
  • ResponseException is parametrised with library-specific deserialisation exception type and http-error type. What previous was ResponseError[E] now would be ResponseException[String, E]
  • streamBody sets application/octet-stream as the content type by default
  • the default execution context used in the akka-http backend is different: instead of global, the EC backing the provided actor system is used
  • for zio backends, the send method has been moved from SttpClient to the package (for consistency with other zio libraries)
  • logging backends have been combined into a single one, exposing various configuration options
sttp - v3.0.0-RC2

Published by adamw about 4 years ago

This is a preview release, containing most of the functionality planned for sttp v3. The code passes all tests, however the API might change.

Breaking changes since v2:

SttpBackend trait

The trait now has 2, instead of 3 parameters. The "default" case of a backend with no additional capabilities changed:

SttpBackend[F, Nothing, NothingT] --> SttpBackend[F, Any]

The second type parameter now contains a list of supported additional capabilities. This can include:

  • an implementation of Streams
  • WebSockets

Finally, the type of supported streams is not given directly, but wrapped in a Streams object. For example, the types of the AkkaHttpBackend and AsyncHttpClientZioBackend backends now are:

SttpBackend[Future, AkkaStreams with WebSockets]
SttpBackend[Task, ZioStreams with WebSockets]

Request type

The type describing a request has undergone similar changes, with the last type parameter specifying the requirements that a backend must meet in order of the request to be sent. The "default" description of a request which doesn't use websockets or streams changed:

Request[T, Nothing] -> Request[T, Any]

Similarly, the type of ResponseAs changed.

The Request.send() method, which used an implicit SttpBackend is deprecated. Instead, use Request.send(backend), giving the backend explicitly.

SttpBackendStub

  • method name change: thenRespondWrapped -> thenRespondF
  • when nothing is stubbed, an exception (failed effect) is thrown, instead of returning 404

Other

  • ResponseError -> ResponseException, but type aliases are provided
  • ResponseException is parametrised with library-specific deserialisation exception type and http-error type. What previous was ResponseError[E] now would be ResponseException[String, E]
  • streamBody sets application/octet-stream as the content type by default
  • the default execution context used in the akka-http backend is different: instead of global, the EC backing the provided actor system is used
  • for zio backends, the send method has been moved from SttpClient to the package (for consistency with other zio libraries)
  • logging backends have been combined into a single one, exposing various configuration options
sttp - v3.0.0-RC1

Published by adamw about 4 years ago

This is a preview release, containing most of the functionality planned for sttp v3. The code passes all tests, however the API might change.

Breaking changes since v2:

SttpBackend trait

The trait now has 2, instead of 3 parameters. The "default" case of a backend with no additional capabilities changed:

SttpBackend[F, Nothing, NothingT] --> SttpBackend[F, Any]

The second type parameter now contains a list of supported additional capabilities. This can include:

  • an implementation of Streams
  • WebSockets

Finally, the type of supported streams is not given directly, but wrapped in a Streams object. For example, the types of the AkkaHttpBackend and AsyncHttpClientZioBackend backends now are:

SttpBackend[Future, AkkaStreams with WebSockets]
SttpBackend[Task, ZioStreams with WebSockets]

Request type

The type describing a request has undergone similar changes, with the last type parameter specifying the requirements that a backend must meet in order of the request to be sent. The "default" description of a request which doesn't use websockets or streams changed:

Request[T, Nothing] -> Request[T, Any]

Similarly, the type of ResponseAs changed.

The Request.send() method, which used an implicit SttpBackend is deprecated. Instead, use Request.send(backend), giving the backend explicitly.

SttpBackendStub

  • method name change: thenRespondWrapped -> thenRespondF
  • when nothing is stubbed, an exception (failed effect) is thrown, instead of returning 404

Other

  • ResponseError -> ResponseException, but type aliases are provided
  • ResponseException is parametrised with library-specific deserialisation exception type and http-error type. What previous was ResponseError[E] now would be ResponseException[String, E]
  • streamBody sets application/octet-stream as the content type by default
  • the default execution context used in the akka-http backend is different: instead of global, the EC backing the provided actor system is used
sttp - sttp-client v2.0.0

Published by adamw over 4 years ago

Major changes

  • renamed the group id from com.softwaremill.sttp to com.softwaremill.sttp.client (organization)
  • renamed the main package from com.softwaremill.sttp to sttp.client (see #288)
  • renamed initial request from sttp to basicRequest
  • reworked response-as (see #284)
    • asString now is an Either[String, String] not a String (no assumptions as to the error type)
    • all json integrations return an Either[ResponseError, B] body
  • added websocket support

See also:

Minor changes

  • removed Request.parseResponseIf
  • removed Response.unsafeBody
  • redirect loops now throw an exception
  • reduce import conflicts with cats:
    • rename Id to Identity (to make working w/ cats easier)
    • move MonadError to another package
  • cats, zio, monix, scalaz backends now return results wrapped in IO/Task when creating a backend
  • backend.close returns a F[Unit] - watch out if you are using lazy wrappers!
  • StatusCode is a proper type
  • Header is a proper type
  • Multipart renamed to Part and generified
  • asFile(overwrite) - removed the overwire parameter
  • QueryFragment(Encoding) in Uri renamed to QuerySegment(Encoding)
  • Uri.parse, Uri.apply removed, replaced with safeApply
  • uri"..." without scheme throws exception
  • SttpBackendStub: instantiated using .stub on "real" backend companion object, instead of using an instance of the "real" backend
sttp - sttp client v2.0.0-RC1

Published by adamw almost 5 years ago

Major changes

  • renamed the group id from com.softwaremill.sttp to com.softwaremill.sttp.client (organization)
  • renamed the main package from com.softwaremill.sttp to sttp.client (see #288)
  • renamed initial request from sttp to basicRequest
  • reworked response-as (see #284)
    • asString now is an Either[String, String] not a String (no assumptions as to the error type)
    • all json integrations return an Either[ResponseError, B] body
  • added websocket support

See also: sttp2: an overview of proposed changes and Websockets in Scala using sttp

Minor changes

  • removed Request.parseResponseIf
  • removed Response.unsafeBody
  • redirect loops now throw an exception
  • reduce import conflicts with cats:
    • rename Id to Identity (to make working w/ cats easier)
    • move MonadError to another package
  • cats, zio, monix, scalaz backends now return results wrapped in IO/Task when creating a backend
  • backend.close returns a F[Unit] - watch out if you are using lazy wrappers!
  • StatusCode is a proper type
  • Header is a proper type
  • Multipart renamed to Part and generified
  • asFile(overwrite) - removed the overwire parameter
  • QueryFragment(Encoding) in Uri renamed to QuerySegment(Encoding)
  • Uri.parse, Uri.apply removed, replaced with safeApply
sttp -

Published by adamw over 5 years ago

This release contains three major changes:

  1. some modules are now published for 2.13: core (jvm & js), akka-http-backend, scalaz, async-http-client-future-backend, async-http-client-scalaz-backend, okhttp-backend, json-common, circe, json4s, spray-json, play-json, brave-backend, prometheus-backend

  2. one of the overload of the RequestT.cookies method now accepts a Iterable[Cookie] instead of a Seq[Cookie].

  3. the async-http-client-cats backend now requires an additional ContextShift[F]. This is needed to shift to another threadpool after sending a request (see https://github.com/softwaremill/sttp/issues/217). Similarly, the -monix backends now shift to the default threadpool after send().

sttp -

Published by adamw about 6 years ago

  • scala-native backend by @pcejrowski, #73
  • quick mode for REPLs by @lihaoyi, #125
  • & of course bug fixes
sttp -

Published by adamw over 6 years ago

  • Scala.JS support by @guymers, see the FetchBackend and FetchMonixBackend: http://sttp.readthedocs.io/en/latest/backends/javascript/fetch.html
  • in case of an error response, it's not deserialized to a String by default. See Response.rawErrorBody and Response.body
  • to include a file in a multipart body, use the multipartFile builder method instead of multipart
sttp - Release 0.0.1

Published by adamw about 7 years ago