GenericRequest

sttp.client4.GenericRequest
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.

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

Graph
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]

Members list

Value members

Abstract methods

def mapResponse[T2](f: T => T2): GenericRequest[T2, R]

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.

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.

Attributes

Concrete methods

def isWebSocket: Boolean
def onlyMetadata: RequestMetadata

Metadata of the request, which doesn't retain the request body, or the response handling specification.

Metadata of the request, which doesn't retain the request body, or the response handling specification.

Attributes

def toCurl: String
def toCurl(sensitiveHeaders: Set[String]): String
def toCurl(omitAcceptEncoding: Boolean): String
def toCurl(sensitiveHeaders: Set[String], omitAcceptEncoding: Boolean): String
def toRfc2616Format: String
def toRfc2616Format(sensitiveHeaders: Set[String]): String

Inherited methods

def acceptEncoding(encoding: String): PR

Attributes

Inherited from:
PartialRequestBuilder

Attributes

Inherited from:
PartialRequestBuilder

Attributes

Inherited from:
PartialRequestBuilder
def body(fs: Seq[(String, String)], encoding: String): PR

Encodes the given parameters as form data. If content type is not yet specified, will be set to application/x-www-form-urlencoded.

Encodes the given parameters as form data. If content type is not yet specified, will be set to application/x-www-form-urlencoded.

If content length is not yet specified, will be set to the length of the number of bytes in the url-encoded parameter string.

Attributes

Inherited from:
PartialRequestBuilder
def body(fs: (String, String)*): PR

Encodes the given parameters as form data using utf-8. If content type is not yet specified, will be set to application/x-www-form-urlencoded.

Encodes the given parameters as form data using utf-8. If content type is not yet specified, will be set to application/x-www-form-urlencoded.

If content length is not yet specified, will be set to the length of the number of bytes in the url-encoded parameter string.

Attributes

Inherited from:
PartialRequestBuilder
def body(fs: Map[String, String], encoding: String): PR

Encodes the given parameters as form data. If content type is not yet specified, will be set to application/x-www-form-urlencoded.

Encodes the given parameters as form data. If content type is not yet specified, will be set to application/x-www-form-urlencoded.

If content length is not yet specified, will be set to the length of the number of bytes in the url-encoded parameter string.

Attributes

Inherited from:
PartialRequestBuilder
def body(fs: Map[String, String]): PR

Encodes the given parameters as form data using utf-8. If content type is not yet specified, will be set to application/x-www-form-urlencoded.

Encodes the given parameters as form data using utf-8. If content type is not yet specified, will be set to application/x-www-form-urlencoded.

If content length is not yet specified, will be set to the length of the number of bytes in the url-encoded parameter string.

Attributes

Inherited from:
PartialRequestBuilder
def body(b: InputStream): PR

If content type is not yet specified, will be set to application/octet-stream.

If content type is not yet specified, will be set to application/octet-stream.

Attributes

Inherited from:
PartialRequestBuilder
def body(b: ByteBuffer): PR

If content type is not yet specified, will be set to application/octet-stream.

If content type is not yet specified, will be set to application/octet-stream.

Attributes

Inherited from:
PartialRequestBuilder
def body(b: Array[Byte]): PR

If content type is not yet specified, will be set to application/octet-stream.

If content type is not yet specified, will be set to application/octet-stream.

If content length is not yet specified, will be set to the length of the given array.

Attributes

Inherited from:
PartialRequestBuilder
def body(b: String, encoding: String): PR

If content type is not yet specified, will be set to text/plain with the given encoding.

If content type is not yet specified, will be set to text/plain with the given encoding.

If content length is not yet specified, will be set to the number of bytes in the string using the given encoding.

Attributes

Inherited from:
PartialRequestBuilder
def body(b: String): PR

Uses the utf-8 encoding.

Uses the utf-8 encoding.

If content type is not yet specified, will be set to text/plain with utf-8 encoding.

If content length is not yet specified, will be set to the number of bytes in the string using the utf-8 encoding.

Attributes

Inherited from:
PartialRequestBuilder
def body[B : BodySerializer](b: B): R

If content type is not yet specified, will be set to application/octet-stream.

If content type is not yet specified, will be set to application/octet-stream.

Attributes

Inherited from:
PartialRequestExtensions
def body(file: File): R

If content type is not yet specified, will be set to application/octet-stream.

If content type is not yet specified, will be set to application/octet-stream.

If content length is not yet specified, will be set to the length of the given file.

Attributes

Inherited from:
PartialRequestExtensions
def contentLength: Option[Long]

Attributes

Inherited from:
HasHeaders
def contentLength(l: Long): PR

Attributes

Inherited from:
PartialRequestBuilder
def contentType: Option[String]

Attributes

Inherited from:
HasHeaders
def contentType(ct: String, encoding: String): PR

Attributes

Inherited from:
PartialRequestBuilder
def contentType(mt: MediaType): PR

Attributes

Inherited from:
PartialRequestBuilder
def contentType(ct: String): PR

Attributes

Inherited from:
PartialRequestBuilder
def cookies: Seq[Either[String, CookieWithMeta]]

Attributes

Inherited from:
HasHeaders
def cookies(nvs: (String, String)*): PR

Attributes

Inherited from:
PartialRequestBuilder
def cookies(cs: Iterable[CookieWithMeta]): PR

Attributes

Inherited from:
PartialRequestBuilder
def cookies(r: Response[_]): PR

Attributes

Inherited from:
PartialRequestBuilder
protected def copyWithBody(body: BasicBody): PR

Attributes

Inherited from:
PartialRequestBuilder
def delete(uri: Uri): R

Attributes

Inherited from:
PartialRequestBuilder

Attributes

Inherited from:
PartialRequestBuilder
def followRedirects(fr: Boolean): PR

Attributes

Inherited from:
PartialRequestBuilder
def get(uri: Uri): R

Attributes

Inherited from:
PartialRequestBuilder
def head(uri: Uri): R

Attributes

Inherited from:
PartialRequestBuilder
def header(h: String): Option[String]

Attributes

Inherited from:
HasHeaders
def header(k: String, ov: Option[String]): PR

Adds the given header to the end of the headers sequence, if the value is defined. Otherwise has no effect.

Adds the given header to the end of the headers sequence, if the value is defined. Otherwise has no effect.

Attributes

Inherited from:
PartialRequestBuilder
def header(k: String, v: String): PR

Adds the given header to the end of the headers sequence.

Adds the given header to the end of the headers sequence.

Attributes

Inherited from:
PartialRequestBuilder
def header(k: String, v: String, replaceExisting: Boolean): PR

Adds the given header to the end of the headers sequence.

Adds the given header to the end of the headers sequence.

Value parameters

replaceExisting

If there's already a header with the same name, should it be replaced?

Attributes

Inherited from:
PartialRequestBuilder
def header(h: Header, replaceExisting: Boolean): PR

Adds the given header to the end of the headers sequence.

Adds the given header to the end of the headers sequence.

Value parameters

replaceExisting

If there's already a header with the same name, should it be replaced?

Attributes

Inherited from:
PartialRequestBuilder
def headers(h: String): Seq[String]

Attributes

Inherited from:
HasHeaders
def headers: Seq[Header]

Attributes

Inherited from:
PartialRequestBuilder
def headers(hs: Seq[Header], replaceExisting: Boolean): PR

Adds the given headers to the end of the headers sequence.

Adds the given headers to the end of the headers sequence.

Attributes

Inherited from:
PartialRequestBuilder
def headers(hs: Header*): PR

Adds the given headers to the end of the headers sequence.

Adds the given headers to the end of the headers sequence.

Attributes

Inherited from:
PartialRequestBuilder
def headers(hs: Map[String, String], replaceExisting: Boolean): PR

Adds the given headers to the end of the headers sequence.

Adds the given headers to the end of the headers sequence.

Value parameters

replaceExisting

If there's already a header with the same name, should it be replaced?

Attributes

Inherited from:
PartialRequestBuilder
def headers(hs: Map[String, String]): PR

Adds the given headers to the end of the headers sequence.

Adds the given headers to the end of the headers sequence.

Attributes

Inherited from:
PartialRequestBuilder
def httpVersion: Option[HttpVersion]

GetHttpVersion from tags in request. Supported only is a few backends

GetHttpVersion from tags in request. Supported only is a few backends

Attributes

Returns

one of values form HttpVersion enum or None

Inherited from:
PartialRequestBuilder
def httpVersion(version: HttpVersion): PR

Allows setting HTTP version per request. Supported only is a few backends

Allows setting HTTP version per request. Supported only is a few backends

Value parameters

version:

one of values from HttpVersion enum.

Attributes

Returns

request with version tag

Inherited from:
PartialRequestBuilder
def logSettings(logRequestBody: Option[Boolean], logResponseBody: Option[Boolean], logRequestHeaders: Option[Boolean], logResponseHeaders: Option[Boolean]): PR

Will only have effect when using the LoggingBackend

Will only have effect when using the LoggingBackend

Attributes

Inherited from:
PartialRequestBuilder

Attributes

Inherited from:
PartialRequestBuilder
def maxRedirects(n: Int): PR

Attributes

Inherited from:
PartialRequestBuilder
def method: Method

Attributes

Inherited from:
RequestMetadata
def method(method: Method, uri: Uri): R

Set the method & uri to the given ones.

Set the method & uri to the given ones.

Attributes

Inherited from:
PartialRequestBuilder
def multipartBody(p1: Part[BasicBodyPart], ps: Part[BasicBodyPart]*): PR

Attributes

Inherited from:
PartialRequestBuilder
def multipartBody(ps: Seq[Part[BasicBodyPart]]): PR

Attributes

Inherited from:
PartialRequestBuilder
def options(uri: Uri): R

Attributes

Inherited from:
PartialRequestBuilder

Attributes

Inherited from:
PartialRequestBuilder
def patch(uri: Uri): R

Attributes

Inherited from:
PartialRequestBuilder
def post(uri: Uri): R

Attributes

Inherited from:
PartialRequestBuilder

Attributes

Inherited from:
PartialRequestBuilder
def put(uri: Uri): R

Attributes

Inherited from:
PartialRequestBuilder
def readTimeout(t: Duration): PR

When the request is sent, if reading the response times out (there's no activity for the given period of time), a failed effect will be returned, or an exception will be thrown

When the request is sent, if reading the response times out (there's no activity for the given period of time), a failed effect will be returned, or an exception will be thrown

Attributes

Inherited from:
PartialRequestBuilder
def redirectToGet(r: Boolean): PR

When a POST or PUT request is redirected, should the redirect be a POST/PUT as well (with the original body), or should the request be converted to a GET without a body.

When a POST or PUT request is redirected, should the redirect be a POST/PUT as well (with the original body), or should the request be converted to a GET without a body.

Note that this only affects 301 and 302 redirects. 303 redirects are always converted, while 307 and 308 redirects always keep the same method.

See https://developer.mozilla.org/en-US/docs/Web/HTTP/Redirections for details.

Attributes

Inherited from:
PartialRequestBuilder
def show(includeBody: Boolean, includeHeaders: Boolean, sensitiveHeaders: Set[String]): String

Attributes

Inherited from:
PartialRequestBuilder
def showBasic: String

Attributes

Inherited from:
PartialRequestBuilder
def tag(k: String): Option[Any]

Attributes

Inherited from:
PartialRequestBuilder
def tag(k: String, v: Any): PR

Attributes

Inherited from:
PartialRequestBuilder
def tags: Map[String, Any]

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

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

Attributes

Inherited from:
PartialRequestBuilder
override def toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
RequestMetadata -> Any
Inherited from:
RequestMetadata
def unsafeCookies: Seq[CookieWithMeta]

Attributes

Inherited from:
HasHeaders
def uri: Uri

Attributes

Inherited from:
RequestMetadata
def withBody(body: BasicBody): PR

Attributes

Inherited from:
PartialRequestBuilder
def withHeaders(headers: Seq[Header]): PR

Replace all headers with the given ones.

Replace all headers with the given ones.

Attributes

Inherited from:
PartialRequestBuilder
def withOptions(options: RequestOptions): PR

Replace all options with the given ones.

Replace all options with the given ones.

Attributes

Inherited from:
PartialRequestBuilder
def withTags(tags: Map[String, Any]): PR

Replace all tags with the given ones.

Replace all tags with the given ones.

Attributes

Inherited from:
PartialRequestBuilder