diff --git a/classes/HTTPApiTable.lua b/classes/HTTPApiTable.lua index 1c7e1ad..2971946 100644 --- a/classes/HTTPApiTable.lua +++ b/classes/HTTPApiTable.lua @@ -11,16 +11,16 @@ local HTTPApiTable = {} --- --- @param request HTTPRequest --- @param callback fun(result:HTTPRequestResult) -function HTTPApiTable:fetch(request, callback) end +function HTTPApiTable.fetch(request, callback) end --- Performs given request asynchronously and returns handle for `HTTPApiTable.fetch_async_get()`. --- --- @param request HTTPRequest --- @return HTTPRequestHandle -function HTTPApiTable:fetch_async(request) end +function HTTPApiTable.fetch_async(request) end --- Return response data for given asynchronous HTTP request. --- --- @param handle HTTPRequestHandle --- @return HTTPRequestResult -function HTTPApiTable:fetch_async_get(handle) end +function HTTPApiTable.fetch_async_get(handle) end diff --git a/definitions/HTTPRequestDefinition.lua b/definitions/HTTPRequestDefinition.lua index 83e499c..c2087c1 100644 --- a/definitions/HTTPRequestDefinition.lua +++ b/definitions/HTTPRequestDefinition.lua @@ -1,19 +1,19 @@ --- Used by `HTTPApiTable.fetch` and `HTTPApiTable.fetch_async`. ---@class HTTPRequest: table local HTTPRequest = { - ---@type string + ---@type string? @The URL to fetch. [required] url = "http://example.org", - ---@type number @Timeout for request to be completed in seconds. Default depends on engine settings. + ---@type number? @Timeout for request to be completed in seconds. Default depends on engine settings. timeout = 10, - ---@type string @`"GET"`, `"POST"`, `"PUT"` or `"DELETE"`. The http method to use. Defaults to "GET". + ---@type string? @`"GET"`, `"POST"`, `"PUT"` or `"DELETE"`. The http method to use. Defaults to "GET". method = "GET", --- Data for the POST, PUT or DELETE request. --- Accepts both a string and a table. If a table is specified, encodes --- table as x-www-form-urlencoded key-value pairs. - ---@type string|table @`"Raw request data string"` or `{field1 = "data1", field2 = "data2"}` + ---@type (string|table)? @`"Raw request data string"` or `{field1 = "data1", field2 = "data2"}` data = "example raw request", ---@type string? @Optional, if specified replaces the default minetest user agent with given string @@ -23,9 +23,9 @@ local HTTPRequest = { --- header strings follow HTTP specification (`"Key: Value"`). extra_headers = { "Accept-Language: en-us", "Accept-Charset: utf-8" }, - ---@type boolean? @Optional, if true performs a multipart HTTP request. --- Default is false. --- Post only, data must be array + ---@type boolean? @Optional, if true performs a multipart HTTP request. multipart = false, --- Deprecated, use `data` instead. Forces `method = "POST"`.