Request

class Request(val url: String)

This class is used to build a request

Parameters

url

The url of the request

Constructors

Link copied to clipboard
constructor(url: String)

Properties

Link copied to clipboard

The body of the request. (Set to empty string to ignore). Defaults to empty string

Link copied to clipboard

The headers of the request. Defaults to map with User-Agent

Link copied to clipboard

The method of the request. Defaults to GET

Link copied to clipboard

The timeout of the request (Set to -1 to disable). Defaults to -1

Link copied to clipboard
val url: String
Link copied to clipboard

True if the request should use the cache, false otherwise. Defaults to true

Functions

Link copied to clipboard
fun body(body: String): Request

Sets the body of the request

Link copied to clipboard

Sends the request and returns a response

Link copied to clipboard

Sets the request method to DELETE

Link copied to clipboard
fun get(): Request

Sets the request method to GET

Link copied to clipboard
fun header(key: String, value: String): Request

Sets the header of the request. If the header already exists, it will be overwritten

Link copied to clipboard
fun post(): Request

Sets the request method to POST

Link copied to clipboard
fun put(): Request

Sets the request method to PUT

Link copied to clipboard
fun timeout(timeout: Int): Request

Sets the timeout of the request

Link copied to clipboard
fun useCache(useCache: Boolean): Request

Sets if the request should use the cache