Documentation for maplib/Url.kt
- data class RequestResult
Request result as string.
- data class RequestResultJson
Request result as json object.
- fun constructor(status: Int, value: JsonObject)
Main constructor
- Parameters
status – s cURL request result status.
value – e Json object value.
- val status : Int
s cURL request result status.
- val value : JsonObject
e Json object value.
- data class RequestResultRaw
Request result as raw value.
- object Request
Request. HTTP request class.
- fun get(url: String, options: Map<String, String> = mapOf()) : RequestResult
Execute get request.
Request option values.
Request options are key-value array. The keys may be:
CONNECTTIMEOUT: val, where val is in seconds (possibly with decimals)
TIMEOUT: val, where val is in seconds. This is the maximum delay for the whole request to complete before being aborted
LOW_SPEED_TIME: val, where val is in seconds. This is the maximum time where the transfer speed should be below the LOW_SPEED_LIMIT (if not specified 1b/s), before the transfer to be considered too slow and aborted
LOW_SPEED_LIMIT: val, where val is in bytes/second. See LOW_SPEED_TIME. Has only effect if LOW_SPEED_TIME is specified too
HEADERS: val, where val is an extra header to use when getting a web page For example “Accept: application/x-ogcwkt”
COOKIE: val, where val is formatted as COOKIE1=VALUE1; COOKIE2=VALUE2;
MAX_RETRY: val, where val is the maximum number of retry attempts if a 502, 503 or 504 HTTP error occurs. Default is 0
RETRY_DELAY: val, where val is the number of seconds between retry attempts. Default is 30
- Parameters
url – URL to execute.
options – the array of key-value pairs - String:String.
- Returns
structure with return status code and String data.
- fun delete(url: String, options: Map<String, String> = mapOf()) : RequestResult
Executes delete request.
- See
Request option values, for a description of the available options.
- Parameters
url – URL to execute.
options – the array of key-value pairs - String:String.
- Returns
structure with return status code and String data.
- fun post(url: String, payload: String, options: Map<String, String> = mapOf()) : RequestResult
Executes post request.
- See
Request option values, for a description of the available options.
- Parameters
url – URL to execute.
payload – Post payload string.
options – the array of key-value pairs - String:String.
- Returns
structure with return status code and String data.
- fun put(url: String, payload: String, options: Map<String, String> = mapOf()) : RequestResult
Executes put request.
- See
Request option values, for a description of the available options.
- Parameters
url – URL to execute.
payload – Post payload string.
options – the array of key-value pairs - String:String.
- Returns
structure with return status code and String data.
- fun getJson(url: String, options: Map<String, String> = mapOf()) : RequestResultJson
Executes get request.
- See
Request option values, for a description of the available options.
- Parameters
url – URL to execute.
options – the array of key-value pairs - String:String.
- Returns
structure with return status code and json data.
- fun postJson(url: String, payload: String, options: Map<String, String> = mapOf()) : RequestResultJson
Executes post request.
- See
Request option values, for a description of the available options.
- Parameters
url – URL to execute.
payload – Post payload.
options – the array of key-value pairs - String:String.
- Returns
structure with return status code and json data.
- fun getRaw(url: String, options: Map<String, String> = mapOf()) : RequestResultRaw
Executes get request. Useful for get images.
- Parameters
url – URL to execute.
options – the array of key-value pairs - String:String.
- Returns
structure with return status code and raw data.
- fun upload(filePath: String, url: String, options: Map<String, String> = mapOf(), callback: ((status: StatusCode, complete: Double, message: String) -> Boolean)? = null) : RequestResultJson
Executes upload request.
- Parameters
filePath – Path to file in file system to upload.
url – URL to execute.
options – the array of key-value pairs - String:String.
callback – callback function to show progress or cancel upload.
- Returns
structure with return status code and json data.
- enum class RequestType
Request type.
GET = 1 : GET request.
POST = 2 : POST request.
PUT = 3 : PUT request.
DELETE = 4 : DELETE request.