android-components / mozilla.components.concept.fetch / Request

Request

data class Request (source)

The Request data class represents a resource request to be send by a Client.

It’s API is inspired by the Request interface of the Web Fetch API: https://developer.mozilla.org/en-US/docs/Web/API/Request

Types

Name Summary
Body class Body : Closeable
A Body to be send with the Request.
CookiePolicy enum class CookiePolicy
Method enum class Method
Request methods.
Redirect enum class Redirect

Constructors

Name Summary
<init> Request(url: String, method: Method = Method.GET, headers: MutableHeaders? = MutableHeaders(), connectTimeout: Pair<Long, TimeUnit>? = null, readTimeout: Pair<Long, TimeUnit>? = null, body: Body? = null, redirect: Redirect = Redirect.FOLLOW, cookiePolicy: CookiePolicy = CookiePolicy.INCLUDE, useCaches: Boolean = true)
The Request data class represents a resource request to be send by a Client.

Properties

Name Summary
body val body: Body?
An optional body to be send with the request.
connectTimeout val connectTimeout: Pair<Long, TimeUnit>?
A timeout to be used when connecting to the resource. If the timeout expires before the connection can be established, a java.net.SocketTimeoutException is raised. A timeout of zero is interpreted as an infinite timeout.
cookiePolicy val cookiePolicy: CookiePolicy
A policy to specify whether or not cookies should be sent with the request, defaults to CookiePolicy.INCLUDE
headers val headers: MutableHeaders?
Optional HTTP headers to be send with the request.
method val method: Method
The request method (GET, POST, ..)
readTimeout val readTimeout: Pair<Long, TimeUnit>?
A timeout to be used when reading from the resource. If the timeout expires before there is data available for read, a java.net.SocketTimeoutException is raised. A timeout of zero is interpreted as an infinite timeout.
redirect val redirect: Redirect
Whether the Client should follow redirects (HTTP 3xx) for this request or not.
url val url: String
The URL of the request.
useCaches val useCaches: Boolean
Whether caches should be used or a network request should be forced, defaults to true (use caches).

Extension Functions

Name Summary
loadResourceAsString fun Any.loadResourceAsString(path: String): String
Loads a file from the resources folder and returns its content as a string object.