Skip to content

Instantly share code, notes, and snippets.

@kahrl

kahrl/gist:6180449

Created Aug 8, 2013
Embed
What would you like to do?
diff --git a/doc/lua_api.txt b/doc/lua_api.txt
index 5247b24..7628fe8 100644
--- a/doc/lua_api.txt
+++ b/doc/lua_api.txt
@@ -1448,6 +1448,19 @@ minetest.place_schematic(pos, schematic, rotation, replacements)
^ If the rotation parameter is omitted, the schematic is not rotated.
^ replacements = {{"oldname", "convert_to"}, ...}
+HTTP:
+minetest.httpfetch(request, func(HTTPFetchResult))
+^ Asynchronously download a file via HTTP
+^ This function only works if server was compiled with cURL support,
+ use minetest.has_feature("httpfetch") to check
+^ request can be a string (containing an URL) or an HTTPFetchRequest table
+^ func is called when the request completes (successfully or otherwise)
+minetest.urlencode(str) -> string
+^ Replace every non-alphanumeric character except - . _ ~ by a percent
+ sign followed by two hex characters. (RFC 3986, section 2.3.)
+minetest.urldecode(str) -> string
+^ The inverse of the former.
+
Random:
minetest.get_connected_players() -> list of ObjectRefs
minetest.hash_node_position({x=,y=,z=}) -> 48-bit integer
@@ -2258,3 +2271,28 @@ HUD Definition (hud_add, hud_get)
offset = {x=0, y=0},
^ See "HUD Element Types"
}
+
+HTTPFetchRequest (httpfetch)
+{
+ url = "<url>",
+ ^ URL, required
+ timeout = 5000,
+ ^ Timeout in milliseconds, defaults to the config setting curl_timeout
+ extra_headers = {},
+ ^ Additional HTTP headers, defaults to an empty list
+ ^ e.g. extra_headers = {"DNT: 1", "Referer: http://www.minetest.net/"}
+}
+
+HTTPFetchResult (httpfetch callback)
+{
+ succeeded = false/true,
+ ^ True if the server could be reached, HTTP response code indicated
+ ^ success (e.g. 200 OK) and there was no error downloading the data
+ timeout = false/true,
+ ^ Did it time out? If this is true then succeeded must be false
+ data = "...",
+ ^ Response content
+ ^ If succeeded == false, this may contain partial data or an error page
+ response_code = <integer>,
+ ^ HTTP response code such as 200 or 404; 0 if unable to reach server
+}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment