forked from premake/premake-core
-
Notifications
You must be signed in to change notification settings - Fork 0
http.get
Tom van Dijck edited this page Aug 30, 2016
·
16 revisions
Perform a HTTP GET request using the specified URL.
http.get(url, { options })url is the URL to be downloaded.
options is a table of options used for this HTTP request.
There are three return values.
resource, result_str, response_code = http.get(url, { options })-
resourceis the content that was retrieved or nil if it could not be retrieved. -
result_stris set to "OK" if successful or contains a description of the failure. -
result_codeis the HTTP result code of the get.
local resource, result_str, response_code = http.get("http://example.com/api.json")function progress(total, current)
local ratio = current / total;
ratio = math.min(math.max(ratio, 0), 1);
local percent = math.floor(ratio * 100);
print("Download progress (" .. percent .. "%/100%)")
end
local resource, result_str, response_code = http.get("http://example.com/api.json", {
progress = progress,
headers = { "From: Premake", "Referer: Premake" },
userpwd = "username:password"
})The previous signature of this function was
http.get(url, progress, headers)and continues to be supported. This is equivalent to
http.get(url, { progress = progress, headers = headers })Premake 5.0 or later.