Skip to content

http.get

João Matos edited this page Sep 21, 2015 · 17 revisions

Gets an HTTP resource from the specified URL as a string.

http.get("url", progress, headers)

Parameters

url is the URL to be downloaded. progress is an optional Lua callback function that receives two numeric arguments representing total and current download progress in bytes. headers is an optional Lua table with HTTP headers to be used on the request.

Return Value

Resource as a string if successful, otherwise nil and an error message.

Examples

local res = http.get("http://example.com/api.json")
local res = http.get("http://example.com/api.json", nil, {"From: Premake", "Referer: Premake"})

Remarks

HTTPS requests are not supported yet.

Availability

Premake 5.0 or later.

See Also

Clone this wiki locally