package client
- Alphabetic
- By Inheritance
- client
- SttpApi
- UriInterpolator
- SttpExtensions
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
- sealed trait BasicRequestBody extends RequestBody[Nothing]
-
sealed
trait
BasicResponseAs[T, +S] extends ResponseAs[T, S]
Response handling specification which isn't derived from another response handling method, but needs to be handled directly by the backend.
-
type
BodySerializer[B] = (B) ⇒ BasicRequestBody
Provide an implicit value of this type to serialize arbitrary classes into a request body.
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).
- case class ByteArrayBody(b: Array[Byte], defaultContentType: Option[MediaType] = ...) extends BasicRequestBody with Product with Serializable
- case class ByteBufferBody(b: ByteBuffer, defaultContentType: Option[MediaType] = ...) extends BasicRequestBody with Product with Serializable
- case class DeserializationError[T](body: String, error: T)(implicit evidence$4: ShowError[T]) extends ResponseError[T] with Product with Serializable
- class DigestAuthenticationBackend[F[_], S, WS_HANDLER[_]] extends SttpBackend[F, S, WS_HANDLER]
-
class
EitherBackend[S, WS_HANDLER[_]] extends SttpBackend[[β$0$]Either[Throwable, β$0$], S, WS_HANDLER]
A synchronous backend that safely wraps SttpBackend exceptions in
Either[Throwable, ?]
'sA synchronous backend that safely wraps SttpBackend exceptions in
Either[Throwable, ?]
's- S
The type of streams that are supported by the backend.
Nothing
, if streaming requests/responses is not supported by this backend.- WS_HANDLER
The type of websocket handlers, that are supported by this backend. The handler is parametrised by the value that is being returned when the websocket is established.
NothingT
, if websockets are not supported.
- type Empty[X] = None.type
- case class FileBody(f: SttpFile, defaultContentType: Option[MediaType] = ...) extends BasicRequestBody with Product with Serializable
- class FollowRedirectsBackend[F[_], S, WS_HANDLER[_]] extends SttpBackend[F, S, WS_HANDLER]
- case class HttpError(body: String, statusCode: StatusCode) extends ResponseError[Nothing] with Product with Serializable
- class HttpURLConnectionBackend extends SttpBackend[Identity, Nothing, NothingT]
- type Identity[X] = X
- case class InputStreamBody(b: InputStream, defaultContentType: Option[MediaType] = ...) extends BasicRequestBody with Product with Serializable
- case class MappedResponseAs[T, T2, S](raw: ResponseAs[T, S], g: (T, ResponseMetadata) ⇒ T2) extends ResponseAs[T2, S] with Product with Serializable
- case class MultipartBody(parts: Seq[Part[BasicRequestBody]]) extends RequestBody[Nothing] with Product with Serializable
- type NothingT[X] = Nothing
- type PartialRequest[T, +S] = RequestT[Empty, T, S]
- type Request[T, +S] = RequestT[Identity, T, S]
- sealed trait RequestBody[+S] extends AnyRef
- case class RequestOptions(followRedirects: Boolean, readTimeout: Duration, maxRedirects: Int, redirectToGet: Boolean) extends Product with Serializable
-
case class
RequestT[U[_], T, +S](method: U[Method], uri: U[Uri], body: RequestBody[S], headers: Seq[Header], response: ResponseAs[T, S], options: RequestOptions, tags: Map[String, Any]) extends RequestTExtensions[U, T, S] with Product with Serializable
Describes a HTTP request, along with a description of how the response body should be handled.
Describes a HTTP request, along with a description of how the response body should be handled.
- U
Specifies if the method & uri are specified. By default can be either: * Empty, which is a type constructor which always resolves to None. This type of request is aliased to PartialRequest: there's no method and uri specified, and the request cannot be sent. * Identity, which is an identity type constructor. This type of request is aliased to Request: the method and uri are specified, and the request can be sent.
- T
The target type, to which the response body should be read.
- 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. An exception to this are streaming responses, which need to fully consumed by the client if such a response type is requested.
- tags
Request-specific tags which can be used by backends for logging, metrics, etc. Not used by default.
- trait RequestTExtensions[U[_], T, +S] extends AnyRef
-
case class
Response[T](body: T, code: StatusCode, statusText: String, headers: Seq[Header], history: List[Response[Unit]]) extends ResponseMetadata with Product with Serializable
- history
If redirects are followed, and there were redirects, contains responses for the intermediate requests. The first response (oldest) comes first.
-
sealed
trait
ResponseAs[+T, +S] extends AnyRef
Describes how response body should be handled.
Describes how response body should be handled.
Apart from the basic cases (ignoring, reading as a byte array, stream 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. Finally, response description can be determined dynamically depending on the response metadata.
A number of
as[Type]
helper methods are available as part of SttpApi and when importingsttp.client._
.- T
Target type as which the response will be read.
- S
If T is a stream, the type of the stream. Otherwise,
Nothing
.
- case class ResponseAsFile(output: SttpFile) extends BasicResponseAs[SttpFile, Nothing] with Product with Serializable
- case class ResponseAsFromMetadata[T, S](f: (ResponseMetadata) ⇒ ResponseAs[T, S]) extends ResponseAs[T, S] with Product with Serializable
- case class ResponseAsStream[T, S]()(implicit responseIsStream: =:=[S, T]) extends BasicResponseAs[T, S] with Product with Serializable
- sealed abstract class ResponseError[+T] extends Exception
- trait ResponseMetadata extends HasHeaders
- type RetryWhen = (Request[_, _], Either[Throwable, Response[_]]) ⇒ Boolean
- trait ShowError[-T] extends AnyRef
- class SpecifyAuthScheme[U[_], T, +S] extends AnyRef
- case class StreamBody[S](s: S) extends RequestBody[S] with Product with Serializable
- case class StringBody(s: String, encoding: String, defaultContentType: Option[MediaType] = Some(MediaType.TextPlain)) extends BasicRequestBody with Product with Serializable
- trait SttpApi extends SttpExtensions with UriInterpolator
-
trait
SttpBackend[F[_], -S, -WS_HANDLER[_]] extends AnyRef
- F
The type constructor in which responses are wrapped. E.g. Identity for synchronous backends, scala.concurrent.Future for asynchronous backends.
- S
The type of streams that are supported by the backend. Nothing, if streaming requests/responses is not supported by this backend.
- WS_HANDLER
The type of websocket handlers that are supported by this backend. The handler is parametrised by the value that is being returned when the websocket is established. NothingT, if websockets are not supported.
- Note
Backends should try to classify exceptions into one of the categories specified by SttpClientException. Other exceptions should be thrown unchanged.
- case class SttpBackendOptions(connectionTimeout: FiniteDuration, proxy: Option[Proxy]) extends Product with Serializable
-
abstract
class
SttpClientException extends Exception
Known exceptions that might occur when using a backend.
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 the response (e.g. a broken socket)
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 SttpBackend.send and SttpBackend.openWebsocket methods might also throw other exceptions, due to programming errors, bugs in the underlying implementations, bugs in sttp or an uncovered exception.
- trait SttpExtensions extends AnyRef
- case class TooManyRedirectsException(uri: Uri, redirects: Int) extends Exception with Product with Serializable
-
class
TryBackend[S, WS_HANDLER[_]] extends SttpBackend[Try, S, WS_HANDLER]
A synchronous backend that safely wraps SttpBackend exceptions in
Try
'sA synchronous backend that safely wraps SttpBackend exceptions in
Try
's- S
The type of streams that are supported by the backend.
Nothing
, if streaming requests/responses is not supported by this backend.- WS_HANDLER
The type of websocket handlers, that are supported by this backend. The handler is parametrised by the value that is being returned when the websocket is established.
NothingT
, if websockets are not supported.
-
implicit
class
UriContext extends AnyRef
- Definition Classes
- UriInterpolator
Value Members
-
val
DefaultReadTimeout: Duration
- Definition Classes
- SttpApi
-
def
asByteArray: ResponseAs[Either[String, Array[Byte]], Nothing]
- Definition Classes
- SttpApi
-
def
asByteArrayAlways: ResponseAs[Array[Byte], Nothing]
- Definition Classes
- SttpApi
-
def
asEither[L, R, S](onError: ResponseAs[L, S], onSuccess: ResponseAs[R, S]): ResponseAs[Either[L, R], S]
- Definition Classes
- SttpApi
-
def
asFile(file: File): ResponseAs[Either[String, File], Nothing]
- Definition Classes
- SttpExtensions
-
def
asFileAlways(file: File): ResponseAs[File, Nothing]
- Definition Classes
- SttpExtensions
-
def
asParams(charset: String): ResponseAs[Either[String, Seq[(String, String)]], Nothing]
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.
- Definition Classes
- SttpApi
-
def
asParams: ResponseAs[Either[String, Seq[(String, String)]], Nothing]
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.- Definition Classes
- SttpApi
-
def
asPath(path: Path): ResponseAs[Either[String, Path], Nothing]
- Definition Classes
- SttpExtensions
-
def
asPathAlways(path: Path): ResponseAs[Path, Nothing]
- Definition Classes
- SttpExtensions
-
def
asStream[S]: ResponseAs[Either[String, S], S]
- Definition Classes
- SttpApi
-
def
asStreamAlways[S]: ResponseAs[S, S]
- Definition Classes
- SttpApi
-
def
asString(charset: String): ResponseAs[Either[String, String], Nothing]
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.
- Definition Classes
- SttpApi
-
def
asString: ResponseAs[Either[String, String], Nothing]
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.- Definition Classes
- SttpApi
-
def
asStringAlways(charset: String): ResponseAs[String, Nothing]
- Definition Classes
- SttpApi
-
def
asStringAlways: ResponseAs[String, Nothing]
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.- Definition Classes
- SttpApi
-
val
basicRequest: RequestT[Empty, Either[String, String], Nothing]
A starting request, with the following modification comparing to
emptyRequest
:Accept-Encoding
is set togzip, deflate
(compression/decompression is handled automatically by the library).A starting request, with the following modification comparing to
emptyRequest
:Accept-Encoding
is set togzip, deflate
(compression/decompression is handled automatically by the library).Reads the response body as an
Either[String, String]
, whereLeft
is used if the status code is non-2xx, andRight
otherwise.- Definition Classes
- SttpApi
-
val
emptyRequest: RequestT[Empty, Either[String, String], Nothing]
An empty request with no headers.
An empty request with no headers.
Reads the response body as an
Either[String, String]
, whereLeft
is used if the status code is non-2xx, andRight
otherwise.- Definition Classes
- SttpApi
-
def
fromMetadata[T, S](f: (ResponseMetadata) ⇒ ResponseAs[T, S]): ResponseAs[T, S]
- Definition Classes
- SttpApi
-
def
ignore: ResponseAs[Unit, Nothing]
- Definition Classes
- SttpApi
-
def
multipart[B](name: String, b: B)(implicit arg0: BodySerializer[B]): Part[BasicRequestBody]
Content type will be set to
application/octet-stream
, can be overridden later using thecontentType
method.Content type will be set to
application/octet-stream
, can be overridden later using thecontentType
method.- Definition Classes
- SttpApi
-
def
multipart(name: String, fs: Seq[(String, String)], encoding: String): Part[BasicRequestBody]
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 thecontentType
method.- Definition Classes
- SttpApi
-
def
multipart(name: String, fs: Seq[(String, String)]): Part[BasicRequestBody]
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 thecontentType
method.- Definition Classes
- SttpApi
-
def
multipart(name: String, fs: Map[String, String], encoding: String): Part[BasicRequestBody]
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 thecontentType
method.- Definition Classes
- SttpApi
-
def
multipart(name: String, fs: Map[String, String]): Part[BasicRequestBody]
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 thecontentType
method.- Definition Classes
- SttpApi
-
def
multipart(name: String, data: InputStream): Part[BasicRequestBody]
Content type will be set to
application/octet-stream
, can be overridden later using thecontentType
method.Content type will be set to
application/octet-stream
, can be overridden later using thecontentType
method.- Definition Classes
- SttpApi
-
def
multipart(name: String, data: ByteBuffer): Part[BasicRequestBody]
Content type will be set to
application/octet-stream
, can be overridden later using thecontentType
method.Content type will be set to
application/octet-stream
, can be overridden later using thecontentType
method.- Definition Classes
- SttpApi
-
def
multipart(name: String, data: Array[Byte]): Part[BasicRequestBody]
Content type will be set to
application/octet-stream
, can be overridden later using thecontentType
method.Content type will be set to
application/octet-stream
, can be overridden later using thecontentType
method.- Definition Classes
- SttpApi
-
def
multipart(name: String, data: String, encoding: String): Part[BasicRequestBody]
Content type will be set to
text/plain
withutf-8
encoding, can be overridden later using thecontentType
method.Content type will be set to
text/plain
withutf-8
encoding, can be overridden later using thecontentType
method.- Definition Classes
- SttpApi
-
def
multipart(name: String, data: String): Part[BasicRequestBody]
Content type will be set to
text/plain
withutf-8
encoding, can be overridden later using thecontentType
method.Content type will be set to
text/plain
withutf-8
encoding, can be overridden later using thecontentType
method.- Definition Classes
- SttpApi
-
def
multipartFile(name: String, data: Path): Part[BasicRequestBody]
Content type will be set to
application/octet-stream
, can be overridden later using thecontentType
method.Content type will be set to
application/octet-stream
, can be overridden later using thecontentType
method.File name will be set to the name of the file.
- Definition Classes
- SttpExtensions
-
def
multipartFile(name: String, data: File): Part[BasicRequestBody]
Content type will be set to
application/octet-stream
, can be overridden later using thecontentType
method.Content type will be set to
application/octet-stream
, can be overridden later using thecontentType
method.File name will be set to the name of the file.
- Definition Classes
- SttpExtensions
-
val
quickRequest: RequestT[Empty, String, Nothing]
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.
- Definition Classes
- SttpApi
- object DigestAuthenticationBackend
- object FollowRedirectsBackend
- object HttpURLConnectionBackend
- object IgnoreResponse extends BasicResponseAs[Unit, Nothing] with Product with Serializable
- object NoBody extends RequestBody[Nothing] with Product with Serializable
- object RequestBody
- object RequestT extends Serializable
- object Response extends Serializable
- object ResponseAs
- object ResponseAsByteArray extends BasicResponseAs[Array[Byte], Nothing] with Product with Serializable
- object ResponseMetadata
- object RetryWhen
- object ShowError
- object SttpBackendOptions extends Serializable
- object SttpClientException extends Serializable
- object TryHttpURLConnectionBackend
- object quick extends SttpApi