sttp.client4

package sttp.client4

Members list

Type members

Classlikes

trait Backend[F[_]] extends GenericBackend[F, Any]

A GenericBackend which doesn't support any capabilities, and uses F to represent side-effects.

A GenericBackend which doesn't support any capabilities, and uses F to represent side-effects.

Attributes

Supertypes
trait GenericBackend[F, Any]
class Object
trait Matchable
class Any
Known subtypes
case class BackendOptions(connectionTimeout: FiniteDuration, proxy: Option[Proxy])

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
sealed trait BasicBody extends GenericRequestBody[Any]

Attributes

Companion
object
Supertypes
trait GenericRequestBody[Any]
class Object
trait Matchable
class Any
Known subtypes
class FileBody
class StringBody
object NoBody
Show all
object BasicBody

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
BasicBody.type
sealed trait BasicBodyPart extends BasicBody, BodyPart[Any]

Attributes

Supertypes
trait BodyPart[Any]
trait BasicBody
trait GenericRequestBody[Any]
class Object
trait Matchable
class Any
Show all
Known subtypes
case class BasicMultipartBody(parts: Seq[Part[BasicBodyPart]]) extends MultipartBody[Any], BasicBody

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait BasicBody
trait MultipartBody[Any]
trait GenericRequestBody[Any]
class Object
trait Matchable
class Any
Show all
sealed trait BodyPart[-S] extends GenericRequestBody[S]

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
class FileBody
class StringBody
class StreamBody[BinaryStream, S]
Show all
case class ByteArrayBody(b: Array[Byte], defaultContentType: MediaType) extends BasicBodyPart

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait BodyPart[Any]
trait BasicBody
trait GenericRequestBody[Any]
class Object
trait Matchable
class Any
Show all
case class ByteBufferBody(b: ByteBuffer, defaultContentType: MediaType) extends BasicBodyPart

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait BodyPart[Any]
trait BasicBody
trait GenericRequestBody[Any]
class Object
trait Matchable
class Any
Show all
case class ConditionalResponseAs[+R](condition: ResponseMetadata => Boolean, responseAs: R)

A wrapper around a ResponseAs to supplement it with a condition on the response metadata.

A wrapper around a ResponseAs to supplement it with a condition on the response metadata.

Used in SttpApi.fromMetadata to condition the response handler upon the response metadata: status code, headers, etc.

Type parameters

R

The type of response

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
case class DeserializationException[DE](body: String, error: DE)(implicit evidence$1: ShowError[DE]) extends ResponseException[Nothing, DE]

Attributes

Supertypes
trait Product
trait Equals
class ResponseException[Nothing, DE]
class Exception
class Throwable
trait Serializable
class Object
trait Matchable
class Any
Show all

Specifies what should happen when adding a header to a request description, and a header with that name already exists. See PartialRequestBuilder.header.

Specifies what should happen when adding a header to a request description, and a header with that name already exists. See PartialRequestBuilder.header.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Add
object Combine
object Replace

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
case class FileBody(f: SttpFile, defaultContentType: MediaType) extends BasicBodyPart

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait BodyPart[Any]
trait BasicBody
trait GenericRequestBody[Any]
class Object
trait Matchable
class Any
Show all
trait GenericBackend[F[_], +P]

A specific implementation of HTTP request sending logic.

A specific implementation of HTTP request sending logic.

The send method '''should not''' be used directly by client code, if possible. Instead, the Request.send, StreamRequest.send, WebSocketRequest.send or WebSocketStreamRequest.send methods (depending on the type of the request) should be used, providing a specific backend instance as a parameter.

When creating an instance of a backend, one of the Backend traits should be mixed in, reflecting the effect type and the P capabilities: Backend, SyncBackend, WebSocketBackend, WebSocketSyncBackend, StreamBackend, WebSocketStreamBackend. This is required in order to provide a better developer experience when sending requests: the resulting type has less type parameters.

Type parameters

F

The effect type used to represent side-effects, such as obtaining the response for a request. E.g. Identity for synchronous backends, scala.concurrent.Future for asynchronous backends.

P

Capabilities supported by this backend, in addition to Effect. This might be Any (no special capabilities), subtype of sttp.capabilities.Streams (the ability to send and receive streaming bodies) or WebSockets (the ability to handle websocket requests).

Attributes

Note

Backends should try to classify known HTTP-related exceptions into one of the categories specified by SttpClientException. Other exceptions are thrown unchanged.

Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait GenericRequest[+T, -R] extends RequestBuilder[GenericRequest[T, R]], RequestMetadata

A generic description of an HTTP request, along with a description of how the response body should be handled.

A generic description of an HTTP request, along with a description of how the response body should be handled.

Client code should use concrete subtypes of this trait. The Request.send, StreamRequest.send, WebSocketRequest.send or WebSocketStreamRequest.send methods should be used to send the request, providing an instance of the appropriate Backend subtype.

However, the request can aso be sent using the GenericBackend.send method, which provides a superset of the required capabilities.

Type parameters

R

The backend capabilities required by the request or response description. This might be Any (no requirements), sttp.capabilities.Effect (the backend must support the given effect type), sttp.capabilities.Streams (the ability to send and receive streaming bodies) or sttp.capabilities.WebSockets (the ability to handle websocket requests).

T

The target type, to which the response body should be read.

Attributes

Supertypes
trait RequestMetadata
trait HasHeaders
class Object
trait Matchable
class Any
Show all
Known subtypes
class Request[T]
class StreamRequest[T, R]
class WebSocketRequest[F, T]
sealed trait GenericRequestBody[-R]

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait BasicBody
class FileBody
class StringBody
object NoBody
trait BodyPart[S]
class StreamBody[BinaryStream, S]
trait MultipartBody[S]
Show all
sealed trait GenericResponseAs[+T, -R]

Generic description of how the response to a GenericRequest should be handled. To set on a request, should be wrapped with an appropriate subtype of ResponseAsDelegate, depending on the R capabilities.

Generic description of how the response to a GenericRequest should be handled. To set on a request, should be wrapped with an appropriate subtype of ResponseAsDelegate, depending on the R capabilities.

Type parameters

R

The backend capabilities required by the response description. This might be Any (no requirements), Effect (the backend must support the given effect type), Streams (the ability to send and receive streaming bodies) or WebSockets (the ability to handle websocket requests).

T

Target type as which the response will be read.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class ResponseAsWebSocket[F, T]
class ResponseAsWebSocketStream[S, Pipe]
class MappedResponseAs[T, T2, R]
class ResponseAsBoth[A, B, R]
class ResponseAsStream[F, T, Stream, S]
class ResponseAsStreamUnsafe[BinaryStream, S]
Show all

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
sealed trait GenericWebSocketResponseAs[T, -R] extends GenericResponseAs[T, R]

Attributes

Supertypes
trait GenericResponseAs[T, R]
class Object
trait Matchable
class Any
Known subtypes
case class HttpError[HE](body: HE, statusCode: StatusCode) extends ResponseException[HE, Nothing]

Attributes

Companion
object
Supertypes
trait Product
trait Equals
class ResponseException[HE, Nothing]
class Exception
class Throwable
trait Serializable
class Object
trait Matchable
class Any
Show all
object HttpError

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
HttpError.type
case object IgnoreResponse extends GenericResponseAs[Unit, Any]

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait GenericResponseAs[Unit, Any]
class Object
trait Matchable
class Any
Show all
Self type
case class InputStreamBody(b: InputStream, defaultContentType: MediaType) extends BasicBodyPart

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait BodyPart[Any]
trait BasicBody
trait GenericRequestBody[Any]
class Object
trait Matchable
class Any
Show all
case class MappedResponseAs[T, T2, R](raw: GenericResponseAs[T, R], g: (T, ResponseMetadata) => T2, showAs: Option[String]) extends GenericResponseAs[T2, R]

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait GenericResponseAs[T2, R]
class Object
trait Matchable
class Any
Show all
sealed trait MultipartBody[S] extends GenericRequestBody[S]

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
case class MultipartStreamBody[S](parts: Seq[Part[BodyPart[S]]]) extends MultipartBody[S]

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait MultipartBody[S]
class Object
trait Matchable
class Any
Show all
case object NoBody extends BasicBody

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait BasicBody
trait GenericRequestBody[Any]
class Object
trait Matchable
class Any
Show all
Self type
NoBody.type
final case class PartialRequest[T](body: BasicBody, headers: Seq[Header], response: ResponseAs[T], options: RequestOptions, tags: Map[String, Any]) extends PartialRequestBuilder[PartialRequest[T], Request[T]]

Describes a partial HTTP request, along with a description of how the response body should be handled. A partial request cannot be sent because the method and uri are not yet specified.

Describes a partial HTTP request, along with a description of how the response body should be handled. A partial request cannot be sent because the method and uri are not yet specified.

Type parameters

T

The target type, to which the response body should be read.

Value parameters

response

Description of how the response body should be handled. Needs to be specified upfront so that the response is always consumed and hence there are no requirements on client code to consume it.

tags

Request-specific tags which can be used by backends for logging, metrics, etc. Empty by default.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait HasHeaders
class Object
trait Matchable
class Any
Show all
trait PartialRequestBuilder[+PR <: PartialRequestBuilder[PR, R], +R] extends HasHeaders, PartialRequestExtensions[PR]

The builder methods of requests or partial requests of type PR.

The builder methods of requests or partial requests of type PR.

Type parameters

PR

The type of the request or partial request. The method and uri may not be specified yet.

R

The type of request when the method and uri are specified.

Attributes

Supertypes
trait HasHeaders
class Object
trait Matchable
class Any
Known subtypes
class PartialRequest[T]
trait RequestBuilder[R]
trait GenericRequest[T, R]
class Request[T]
class StreamRequest[T, R]
class WebSocketRequest[F, T]
Show all
Self type
PR

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait PartialRequestBuilder[PR, R]
class PartialRequest[T]
trait RequestBuilder[R]
trait GenericRequest[T, R]
class Request[T]
class StreamRequest[T, R]
class WebSocketRequest[F, T]
Show all
Self type
R
case class Request[T](method: Method, uri: Uri, body: BasicBody, headers: Seq[Header], response: ResponseAs[T], options: RequestOptions, tags: Map[String, Any]) extends GenericRequest[T, Any], RequestBuilder[Request[T]]

Describes an HTTP request, along with a description of how the response body should be handled.

Describes an HTTP request, along with a description of how the response body should be handled.

The request can be sent using an instance of SyncBackend or Backend with the send method.

Type parameters

T

The target type, to which the response body should be read.

Value parameters

response

Description of how the response body should be handled. Needs to be specified upfront so that the response is always consumed and hence there are no requirements on client code to consume it.

tags

Request-specific tags which can be used by backends for logging, metrics, etc. Empty by default.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait GenericRequest[T, Any]
trait RequestMetadata
trait HasHeaders
class Object
trait Matchable
class Any
Show all
object Request

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Request.type
trait RequestBuilder[+R <: RequestBuilder[R]] extends PartialRequestBuilder[R, R]

The builder methods of a request. The uri and method are specified.

The builder methods of a request. The uri and method are specified.

Type parameters

R

The type of request

Attributes

Supertypes
trait PartialRequestBuilder[R, R]
trait HasHeaders
class Object
trait Matchable
class Any
Show all
Known subtypes
trait GenericRequest[T, R]
class Request[T]
class StreamRequest[T, R]
class WebSocketRequest[F, T]
Self type
R
case class RequestOptions(followRedirects: Boolean, readTimeout: Duration, maxRedirects: Int, redirectToGet: Boolean)

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class Response[+T](body: T, code: StatusCode, statusText: String, headers: Seq[Header], history: List[Response[Unit]], request: RequestMetadata) extends ResponseMetadata

Value parameters

history

If redirects are followed, and there were redirects, contains responses for the intermediate requests. The first response (oldest) comes first.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait ResponseMetadata
trait HasHeaders
class Object
trait Matchable
class Any
Show all
case class ResponseAs[+T](delegate: GenericResponseAs[T, Any]) extends ResponseAsDelegate[T, Any]

Describes how the response body of a Request should be handled.

Describes how the response body of a Request should be handled.

Apart from the basic cases (ignoring, reading as a byte array or file), response body descriptions can be mapped over, to support custom types. The mapping can take into account the ResponseMetadata, that is the headers and status code. Responses can also be handled depending on the response metadata. Finally, two response body descriptions can be combined (with some restrictions).

A number of as<Type> helper methods are available as part of SttpApi and when importing sttp.client4._.

Type parameters

T

Target type as which the response will be read.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait ResponseAsDelegate[T, Any]
class Object
trait Matchable
class Any
Show all
object ResponseAs

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
ResponseAs.type
case class ResponseAsBoth[A, B, R](l: GenericResponseAs[A, R], r: GenericResponseAs[B, Any]) extends GenericResponseAs[(A, Option[B]), R]

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait GenericResponseAs[(A, Option[B]), R]
class Object
trait Matchable
class Any
Show all
case object ResponseAsByteArray extends GenericResponseAs[Array[Byte], Any]

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait GenericResponseAs[Array[Byte], Any]
class Object
trait Matchable
class Any
Show all
Self type
trait ResponseAsDelegate[+T, -R]

Describes how the response body of a request should be handled. A number of as<Type> helper methods are available as part of SttpApi and when importing sttp.client4._. These methods yield specific implementations of this trait, which can then be set on a Request, StreamRequest, WebSocketRequest or WebSocketStreamRequest, depending on the response type.

Describes how the response body of a request should be handled. A number of as<Type> helper methods are available as part of SttpApi and when importing sttp.client4._. These methods yield specific implementations of this trait, which can then be set on a Request, StreamRequest, WebSocketRequest or WebSocketStreamRequest, depending on the response type.

Type parameters

R

The backend capabilities required by the response description. This might be Any (no requirements), sttp.capabilities.Effect (the backend must support the given effect type), sttp.capabilities.Streams (the ability to send and receive streaming bodies) or sttp.capabilities.WebSockets (the ability to handle websocket requests).

T

Target type as which the response will be read.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
class ResponseAs[T]
class StreamResponseAs[T, S]
case class ResponseAsFile(output: SttpFile) extends GenericResponseAs[SttpFile, Any]

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class ResponseAsFromMetadata[T, R](conditions: List[ConditionalResponseAs[GenericResponseAs[T, R]]], default: GenericResponseAs[T, R]) extends GenericResponseAs[T, R]

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait GenericResponseAs[T, R]
class Object
trait Matchable
class Any
Show all
case class ResponseAsInputStream[T](f: InputStream => T) extends GenericResponseAs[T, Any]

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait GenericResponseAs[T, Any]
class Object
trait Matchable
class Any
Show all
case object ResponseAsInputStreamUnsafe extends GenericResponseAs[InputStream, Any]

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait GenericResponseAs[InputStream, Any]
class Object
trait Matchable
class Any
Show all
Self type
case class ResponseAsStream[F[_], T, Stream, S] extends GenericResponseAs[T, S & Effect[F]]

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait GenericResponseAs[T, S & Effect[F]]
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
case class ResponseAsStreamUnsafe[BinaryStream, S] extends GenericResponseAs[BinaryStream, S]

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait GenericResponseAs[BinaryStream, S]
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
case class ResponseAsWebSocket[F[_], T](f: (WebSocket[F], ResponseMetadata) => F[T]) extends GenericWebSocketResponseAs[T, WebSockets & Effect[F]]

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait GenericWebSocketResponseAs[T, WebSockets & Effect[F]]
trait GenericResponseAs[T, WebSockets & Effect[F]]
class Object
trait Matchable
class Any
Show all
case class ResponseAsWebSocketStream[S, Pipe[_, _]](s: Streams[S], p: Pipe[Data[_], WebSocketFrame]) extends GenericWebSocketResponseAs[Unit, S & WebSockets]

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait GenericWebSocketResponseAs[Unit, S & WebSockets]
trait GenericResponseAs[Unit, S & WebSockets]
class Object
trait Matchable
class Any
Show all
case class ResponseAsWebSocketUnsafe[F[_]]() extends GenericWebSocketResponseAs[WebSocket[F], WebSockets & Effect[F]]

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait GenericWebSocketResponseAs[WebSocket[F], WebSockets & Effect[F]]
trait GenericResponseAs[WebSocket[F], WebSockets & Effect[F]]
class Object
trait Matchable
class Any
Show all
sealed abstract class ResponseException[+HE, +DE](error: String) extends Exception

Attributes

Supertypes
class Exception
class Throwable
trait Serializable
class Object
trait Matchable
class Any
Show all
Known subtypes
class HttpError[HE]
object RetryWhen

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
RetryWhen.type
trait ShowError[-T]

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
object ShowError

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
ShowError.type
class SpecifyAuthScheme[+R <: PartialRequestBuilder[R, _]](hn: String, req: R, digestTag: String)

Attributes

Supertypes
class Object
trait Matchable
class Any
trait StreamBackend[F[_], +S] extends Backend[F], GenericBackend[F, S]

A GenericBackend which supports streams of type S and uses F to represent side-effects.

A GenericBackend which supports streams of type S and uses F to represent side-effects.

Attributes

Supertypes
trait Backend[F]
trait GenericBackend[F, S]
class Object
trait Matchable
class Any
Known subtypes
case class StreamBody[BinaryStream, S] extends BodyPart[S]

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait BodyPart[S]
class Object
trait Matchable
class Any
Show all
object StreamBody

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
StreamBody.type
final case class StreamRequest[T, R](method: Method, uri: Uri, body: GenericRequestBody[R], headers: Seq[Header], response: StreamResponseAs[T, R], options: RequestOptions, tags: Map[String, Any]) extends GenericRequest[T, R], RequestBuilder[StreamRequest[T, R]]

Describes an HTTP request, along with a description of how the response body should be handled. Either the request or response body uses non-blocking, asynchronous streams.

Describes an HTTP request, along with a description of how the response body should be handled. Either the request or response body uses non-blocking, asynchronous streams.

The request can be sent using an instance of StreamBackend with the send method.

Type parameters

R

The capabilities required to send this request: a subtype of Streams, and optionally an Effect.

T

The target type, to which the response body should be read. If the response body is streamed, this might be the value obtained by processing the entire stream.

Value parameters

response

Description of how the response body should be handled. Needs to be specified upfront so that the response is always consumed and hence there are no requirements on client code to consume it.

tags

Request-specific tags which can be used by backends for logging, metrics, etc. Empty by default.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait GenericRequest[T, R]
trait RequestMetadata
trait HasHeaders
class Object
trait Matchable
class Any
Show all
case class StreamResponseAs[+T, S](delegate: GenericResponseAs[T, S]) extends ResponseAsDelegate[T, S]

Describes how the response body of a StreamRequest should be handled.

Describes how the response body of a StreamRequest should be handled.

The stream response can be mapped over, to support custom types. The mapping can take into account the ResponseMetadata, that is the headers and status code.

A number of asStream[Type] helper methods are available as part of SttpApi and when importing sttp.client4._.

Type parameters

S

The type of stream, used to receive the response body bodies.

T

Target type as which the response will be read.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait ResponseAsDelegate[T, S]
class Object
trait Matchable
class Any
Show all
case class StringBody(s: String, encoding: String, defaultContentType: MediaType) extends BasicBodyPart

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait BodyPart[Any]
trait BasicBody
trait GenericRequestBody[Any]
class Object
trait Matchable
class Any
Show all
trait SttpApi extends SttpExtensions, UriInterpolator

Attributes

Supertypes
trait UriInterpolator
class Object
trait Matchable
class Any
Known subtypes
object quick
abstract class SttpClientException(val request: GenericRequest[_, _], val cause: Exception) extends Exception

Known exceptions that might occur when using a backend. Currently this covers:

Known exceptions that might occur when using a backend. Currently this covers:

  • connect exceptions: when a connection (tcp socket) can't be established to the target host
  • read exceptions: when a connection has been established, but there's any kind of problem receiving or handling the response (e.g. a broken socket or a deserialization error)

In general, it's safe to assume that the request hasn't been sent in case of connect exceptions. With read exceptions, the target host might or might have not received and processed the request.

The Backend.send methods might also throw other exceptions, due to programming errors, bugs in the underlying implementations, bugs in sttp or an uncovered exception.

Value parameters

cause

The original exception.

request

The request, which was being sent when the exception was thrown

Attributes

Companion
object
Supertypes
class Exception
class Throwable
trait Serializable
class Object
trait Matchable
class Any
Show all
Known subtypes

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait SttpApi
object quick

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
object async

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
object stream

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
object sync
trait SyncBackend extends Backend[Identity]

A GenericBackend which is synchronous (side effects are run directly), and doesn't support any capabilities.

A GenericBackend which is synchronous (side effects are run directly), and doesn't support any capabilities.

Attributes

Supertypes
trait Backend[Identity]
trait GenericBackend[Identity, Any]
class Object
trait Matchable
class Any
Known subtypes

Attributes

Supertypes
class Object
trait Matchable
class Any
trait WebSocketBackend[F[_]] extends Backend[F], GenericBackend[F, WebSockets]

A GenericBackend which supports web sockets and uses F to represent side-effects.

A GenericBackend which supports web sockets and uses F to represent side-effects.

Attributes

Supertypes
trait Backend[F]
trait GenericBackend[F, WebSockets]
class Object
trait Matchable
class Any
Known subtypes
object WebSocketImpl

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
final case class WebSocketRequest[F[_], T](method: Method, uri: Uri, body: BasicBody, headers: Seq[Header], response: WebSocketResponseAs[F, T], options: RequestOptions, tags: Map[String, Any]) extends GenericRequest[T, WebSockets & Effect[F]], RequestBuilder[WebSocketRequest[F, T]]

Describes an HTTP WebSocket request.

Describes an HTTP WebSocket request.

The request can be sent using an instance of WebSocketBackend with the send method.

Type parameters

F

The effect type used to process the WebSocket. Might include asynchronous computations (e.g. scala.concurrent.Future), pure effect descriptions (IO), or synchronous computations (Identity).

T

The target type, to which the response body should be read. If the WebSocket interactions are described entirely by the response description, this might be Unit. Otherwise, this can be a sttp.ws.WebSocket instance.

Value parameters

response

Description of how the WebSocket should be handled. Needs to be specified upfront so that the response is always consumed and hence there are no requirements on client code to consume it.

tags

Request-specific tags which can be used by backends for logging, metrics, etc. Empty by default.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait GenericRequest[T, WebSockets & Effect[F]]
trait RequestMetadata
trait HasHeaders
class Object
trait Matchable
class Any
Show all
trait WebSocketStreamBackend[F[_], S] extends WebSocketBackend[F], StreamBackend[F, S], GenericBackend[F, S & WebSockets]

A GenericBackend which supports websockets, streams of type S and uses F to represent side-effects.

A GenericBackend which supports websockets, streams of type S and uses F to represent side-effects.

Attributes

Supertypes
trait StreamBackend[F, S]
trait WebSocketBackend[F]
trait Backend[F]
trait GenericBackend[F, S & WebSockets]
class Object
trait Matchable
class Any
Show all
Known subtypes
final case class WebSocketStreamRequest[T, S](method: Method, uri: Uri, body: GenericRequestBody[S], headers: Seq[Header], response: WebSocketStreamResponseAs[T, S], options: RequestOptions, tags: Map[String, Any]) extends GenericRequest[T, S & WebSockets], RequestBuilder[WebSocketStreamRequest[T, S]]

Describes an HTTP WebSocket request. Either the request body, or the WebSocket handling uses non-blocking, asynchronous streams.

Describes an HTTP WebSocket request. Either the request body, or the WebSocket handling uses non-blocking, asynchronous streams.

The request can be sent using an instance of WebSocketStreamBackend with the send method.

Type parameters

S

The stream capability required to send this request, a subtype of Streams.

T

The target type, to which the response body should be read. If the WebSocket interactions are described entirely by the response description, this might be Unit. Otherwise, this can be an S stream of frames or mapped WebSocket messages.

Value parameters

response

Description of how the WebSocket should be handled. Needs to be specified upfront so that the response is always consumed and hence there are no requirements on client code to consume it.

tags

Request-specific tags which can be used by backends for logging, metrics, etc. Empty by default.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait GenericRequest[T, S & WebSockets]
trait RequestMetadata
trait HasHeaders
class Object
trait Matchable
class Any
Show all

A GenericBackend which is synchronous (side effects are run directly), and supports web sockets.

A GenericBackend which is synchronous (side effects are run directly), and supports web sockets.

Attributes

Supertypes
trait SyncBackend
trait Backend[Identity]
trait GenericBackend[Identity, WebSockets]
class Object
trait Matchable
class Any
Show all
Known subtypes
object quick extends SttpApi

Attributes

Supertypes
trait SttpApi
trait UriInterpolator
class Object
trait Matchable
class Any
Show all
Self type
quick.type

Inherited classlikes

implicit class UriContext(val sc: StringContext)

Attributes

Inherited from:
UriInterpolator
Supertypes
class Object
trait Matchable
class Any

Types

type BodySerializer[B] = B => BasicBodyPart

Provide an implicit value of this type to serialize arbitrary classes into a request body. Backends might also provide special logic for serializer instances which they define (e.g. to handle streaming).

Provide an implicit value of this type to serialize arbitrary classes into a request body. Backends might also provide special logic for serializer instances which they define (e.g. to handle streaming).

Attributes

type Identity[+X] = X
type RetryWhen = (GenericRequest[_, _], Either[Throwable, Response[_]]) => Boolean

Value members

Inherited methods

def asBoth[A, B](l: ResponseAs[A], r: ResponseAs[B]): ResponseAs[(A, B)]

Use both l and r to read the response body. Neither response specifications may use streaming or web sockets.

Use both l and r to read the response body. Neither response specifications may use streaming or web sockets.

Attributes

Inherited from:
SttpApi
def asBothOption[A, B, S](l: StreamResponseAs[A, S], r: ResponseAs[B]): StreamResponseAs[(A, Option[B]), S]

Use l to read the response body. If the raw body value which is used by l is replayable (a file or byte array), also use r to read the response body. Otherwise ignore r (if the raw body is a stream).

Use l to read the response body. If the raw body value which is used by l is replayable (a file or byte array), also use r to read the response body. Otherwise ignore r (if the raw body is a stream).

Attributes

Inherited from:
SttpApi
def asBothOption[A, B](l: ResponseAs[A], r: ResponseAs[B]): ResponseAs[(A, Option[B])]

Use l to read the response body. If the raw body value which is used by l is replayable (a file or byte array), also use r to read the response body. Otherwise ignore r (if the raw body is a stream).

Use l to read the response body. If the raw body value which is used by l is replayable (a file or byte array), also use r to read the response body. Otherwise ignore r (if the raw body is a stream).

Attributes

Inherited from:
SttpApi
def asByteArray: ResponseAs[Either[String, Array[Byte]]]

Attributes

Inherited from:
SttpApi
def asByteArrayAlways: ResponseAs[Array[Byte]]

Attributes

Inherited from:
SttpApi
def asEither[A, B, S](onError: ResponseAs[A], onSuccess: StreamResponseAs[B, S]): StreamResponseAs[Either[A, B], S]

Uses the onSuccess response specification for successful responses (2xx), and the onError specification otherwise.

Uses the onSuccess response specification for successful responses (2xx), and the onError specification otherwise.

Attributes

Inherited from:
SttpApi
def asEither[A, B](onError: ResponseAs[A], onSuccess: ResponseAs[B]): ResponseAs[Either[A, B]]

Uses the onSuccess response specification for successful responses (2xx), and the onError specification otherwise.

Uses the onSuccess response specification for successful responses (2xx), and the onError specification otherwise.

Attributes

Inherited from:
SttpApi
def asFile(file: File): ResponseAs[Either[String, File]]

Attributes

Inherited from:
SttpExtensions
def asFileAlways(file: File): ResponseAs[File]

Attributes

Inherited from:
SttpExtensions
def asParams(charset: String): ResponseAs[Either[String, Seq[(String, String)]]]

Use the given charset by default, unless specified otherwise in the response headers.

Use the given charset by default, unless specified otherwise in the response headers.

Attributes

Inherited from:
SttpApi
def asParams: ResponseAs[Either[String, Seq[(String, String)]]]

Use the utf-8 charset by default, unless specified otherwise in the response headers.

Use the utf-8 charset by default, unless specified otherwise in the response headers.

Attributes

Inherited from:
SttpApi
def asParamsAlways(charset: String): ResponseAs[Seq[(String, String)]]

Use the given charset by default, unless specified otherwise in the response headers.

Use the given charset by default, unless specified otherwise in the response headers.

Attributes

Inherited from:
SttpApi
def asParamsAlways: ResponseAs[Seq[(String, String)]]

Use the utf-8 charset by default, unless specified otherwise in the response headers.

Use the utf-8 charset by default, unless specified otherwise in the response headers.

Attributes

Inherited from:
SttpApi
def asStream[F[_], T, S](s: Streams[S])(f: s.BinaryStream => F[T]): StreamResponseAs[Either[String, T], S & Effect[F]]

Attributes

Inherited from:
SttpApi
def asStreamAlways[F[_], T, S](s: Streams[S])(f: s.BinaryStream => F[T]): StreamResponseAs[T, S & Effect[F]]

Attributes

Inherited from:
SttpApi
def asStreamAlwaysUnsafe[S](s: Streams[S]): StreamResponseAs[s.BinaryStream, S]

Attributes

Inherited from:
SttpApi
def asStreamAlwaysWithMetadata[F[_], T, S](s: Streams[S])(f: (s.BinaryStream, ResponseMetadata) => F[T]): StreamResponseAs[T, S & Effect[F]]

Attributes

Inherited from:
SttpApi
def asStreamUnsafe[S](s: Streams[S]): StreamResponseAs[Either[String, s.BinaryStream], S]

Attributes

Inherited from:
SttpApi
def asStreamWithMetadata[F[_], T, S](s: Streams[S])(f: (s.BinaryStream, ResponseMetadata) => F[T]): StreamResponseAs[Either[String, T], S & Effect[F]]

Attributes

Inherited from:
SttpApi
def asString(charset: String): ResponseAs[Either[String, String]]

Use the given charset by default, unless specified otherwise in the response headers.

Use the given charset by default, unless specified otherwise in the response headers.

Attributes

Inherited from:
SttpApi
def asString: ResponseAs[Either[String, String]]

Use the utf-8 charset by default, unless specified otherwise in the response headers.

Use the utf-8 charset by default, unless specified otherwise in the response headers.

Attributes

Inherited from:
SttpApi
def asStringAlways(charset: String): ResponseAs[String]

Attributes

Inherited from:
SttpApi
def asStringAlways: ResponseAs[String]

Use the utf-8 charset by default, unless specified otherwise in the response headers.

Use the utf-8 charset by default, unless specified otherwise in the response headers.

Attributes

Inherited from:
SttpApi
def fromMetadata[T, S](default: ResponseAs[T], conditions: ConditionalResponseAs[StreamResponseAs[T, S]]*): StreamResponseAs[T, S]

Attributes

Inherited from:
SttpApi
def fromMetadata[T](default: ResponseAs[T], conditions: ConditionalResponseAs[ResponseAs[T]]*): ResponseAs[T]

Attributes

Inherited from:
SttpApi
def ignore: ResponseAs[Unit]

Attributes

Inherited from:
SttpApi
def multipart[B : BodySerializer](name: String, b: B): Part[BasicBodyPart]

Content type will be set to application/octet-stream, can be overridden later using the contentType method.

Content type will be set to application/octet-stream, can be overridden later using the contentType method.

Attributes

Inherited from:
SttpApi
def multipart(name: String, fs: Seq[(String, String)], encoding: String): Part[BasicBodyPart]

Encodes the given parameters as form data.

Encodes the given parameters as form data.

Content type will be set to application/x-www-form-urlencoded, can be overridden later using the contentType method.

Attributes

Inherited from:
SttpApi
def multipart(name: String, fs: Seq[(String, String)]): Part[BasicBodyPart]

Encodes the given parameters as form data using utf-8.

Encodes the given parameters as form data using utf-8.

Content type will be set to application/x-www-form-urlencoded, can be overridden later using the contentType method.

Attributes

Inherited from:
SttpApi
def multipart(name: String, fs: Map[String, String], encoding: String): Part[BasicBodyPart]

Encodes the given parameters as form data.

Encodes the given parameters as form data.

Content type will be set to application/x-www-form-urlencoded, can be overridden later using the contentType method.

Attributes

Inherited from:
SttpApi
def multipart(name: String, fs: Map[String, String]): Part[BasicBodyPart]

Encodes the given parameters as form data using utf-8.

Encodes the given parameters as form data using utf-8.

Content type will be set to application/x-www-form-urlencoded, can be overridden later using the contentType method.

Attributes

Inherited from:
SttpApi
def multipart(name: String, data: InputStream): Part[BasicBodyPart]

Content type will be set to application/octet-stream, can be overridden later using the contentType method.

Content type will be set to application/octet-stream, can be overridden later using the contentType method.

Attributes

Inherited from:
SttpApi
def multipart(name: String, data: ByteBuffer): Part[BasicBodyPart]

Content type will be set to application/octet-stream, can be overridden later using the contentType method.

Content type will be set to application/octet-stream, can be overridden later using the contentType method.

Attributes

Inherited from:
SttpApi
def multipart(name: String, data: Array[Byte]): Part[BasicBodyPart]

Content type will be set to application/octet-stream, can be overridden later using the contentType method.

Content type will be set to application/octet-stream, can be overridden later using the contentType method.

Attributes

Inherited from:
SttpApi
def multipart(name: String, data: String, encoding: String): Part[BasicBodyPart]

Content type will be set to text/plain with given encoding, can be overridden later using the contentType method.

Content type will be set to text/plain with given encoding, can be overridden later using the contentType method.

Attributes

Inherited from:
SttpApi
def multipart(name: String, data: String): Part[BasicBodyPart]

Content type will be set to text/plain with utf-8 encoding, can be overridden later using the contentType method.

Content type will be set to text/plain with utf-8 encoding, can be overridden later using the contentType method.

Attributes

Inherited from:
SttpApi
def multipartFile(name: String, file: File): Part[BasicBodyPart]

Content type will be set to application/octet-stream, can be overridden later using the contentType method.

Content type will be set to application/octet-stream, can be overridden later using the contentType method.

File name will be set to the name of the file.

Attributes

Inherited from:
SttpExtensions
def multipartStream[S](s: Streams[S])(name: String, b: s.BinaryStream): Part[StreamBody[s.BinaryStream, S]]

Content type will be set to application/octet-stream, can be overridden later using the contentType method.

Content type will be set to application/octet-stream, can be overridden later using the contentType method.

Attributes

Inherited from:
SttpApi

Inherited fields

val DefaultReadTimeout: Duration

Attributes

Inherited from:
SttpApi
val basicRequest: PartialRequest[Either[String, String]]

A starting request, with the following modification comparing to emptyRequest: Accept-Encoding is set to gzip, deflate (compression/decompression is handled automatically by the library).

A starting request, with the following modification comparing to emptyRequest: Accept-Encoding is set to gzip, deflate (compression/decompression is handled automatically by the library).

Reads the response body as an Either[String, String], where Left is used if the status code is non-2xx, and Right otherwise.

Attributes

Inherited from:
SttpApi
val emptyRequest: PartialRequest[Either[String, String]]

An empty request with no headers.

An empty request with no headers.

Reads the response body as an Either[String, String], where Left is used if the status code is non-2xx, and Right otherwise.

Attributes

Inherited from:
SttpApi

A starting request which always reads the response body as a string, regardless of the status code.

A starting request which always reads the response body as a string, regardless of the status code.

Attributes

Inherited from:
SttpApi

Implicits

Inherited implicits

final implicit def UriContext(sc: StringContext): UriContext

Attributes

Inherited from:
UriInterpolator