Documentation for MapLib/Url.swift¶
- class Request¶
HTTP request class.
- static func get(url: String, options: [String: String]? = nil) (status: Int, value: String) ¶
Executes 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
- See also
Request option values
, for a description of the available options.- Параметры
url – URL to execute.
options – the array of key-value pairs - String: String.
- Результат
structure with return status code and String data.
- static func delete(url: String, options: [String: String]? = nil) (status: Int, value: String) ¶
Executes delete request.
- See also
Request option values
, for a description of the available options.- Параметры
url – URL to execute.
options – the array of key-value pairs - String: String.
- Результат
structure with return status code and String data.
- static func post(url: String, payload: String, options: [String: String]? = nil) (status: Int, value: String) ¶
Executes post request.
- See also
Request option values
, for a description of the available options.- Параметры
url – URL to execute.
payload – Post payload string.
options – the array of key-value pairs - String: String.
- Результат
structure with return status code and String data.
- static func put(url: String, payload: String, options: [String: String]? = nil) (status: Int, value: String) ¶
Executes put request.
- See also
Request option values
, for a description of the available options.- Параметры
url – URL to execute.
payload – Put payload string.
options – the array of key-value pairs - String: String.
- Результат
structure with return status code and String data.
- static func getJson(url: String, options: [String: String]? = nil) (status: Int, value: Any?) ¶
Executes get request.
- Параметры
url – URL to execute.
options – the array of key-value pairs - String: String.
- Результат
structure with return status code and json data.
- static func postJson(url: String, payload: String, options: [String: String]? = nil) (status: Int, value: Any?) ¶
Executes post request.
- Параметры
url – URL to execute.
payload – Post payload.
options – the array of key-value pairs - String: String.
- Результат
structure with return status code and json data.
- static func getRaw(url: String, options: [String: String]? = nil) (status: Int, value: [UInt8]?) ¶
Executes get request. Useful for get images.
- Параметры
url – URL to execute.
options – the array of key-value pairs - String: String.
- Результат
structure with return status code and raw data.
- static func upload()¶
Executes upload request.
- Параметры
path – 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.
- Результат
structure with return status code and json data.