DefaultHttpClient
class DefaultHttpClient(userAgent: String? = null, connectTimeout: Duration? = null, readTimeout: Duration? = null, var callback: DefaultHttpClient.Callback = object : Callback {}) : HttpClient
An implementation of HttpClient using the native HttpURLConnection.
Parameters
userAgent
Custom user agent to use for requests.
connectTimeout
Timeout used when establishing a connection to the resource. A null timeout is interpreted as the default value, while a timeout of zero as an infinite timeout.
readTimeout
Timeout used when reading the input stream. A null timeout is interpreted as the default value, while a timeout of zero as an infinite timeout.
Constructors
Link copied to clipboard
constructor(userAgent: String? = null, connectTimeout: Duration? = null, readTimeout: Duration? = null, callback: DefaultHttpClient.Callback = object : Callback {})
Types
Link copied to clipboard
interface Callback
Callbacks allowing to override some behavior of the DefaultHttpClient.
Functions
Link copied to clipboard
Fetches the resource from the given request.
Link copied to clipboard
Fetches the resource from the given request as a JSONObject.
Link copied to clipboard
suspend fun HttpClient.fetchString(request: HttpRequest, charset: Charset = Charsets.UTF_8): HttpTry<String>
Link copied to clipboard
suspend fun <T> HttpClient.fetchWithDecoder(request: HttpRequest, decoder: (HttpFetchResponse) -> T): HttpTry<T>
Link copied to clipboard
Performs a HEAD request to retrieve only the response headers.
Link copied to clipboard
Streams the resource from the given request.