There was an undocumented return code from http.download which was the
numerical CURL error code.
This has been replaced with the HTTP response code. The return for
http.download is now error message, HTTP response code. This could
break code that was relying on the CURL error but my light research is
that users of this call were checking for the error message being “OK”
and that functionality is preserved.
http.get has been updated to have a consistent return signature to
http.download and now returns the result, error message, HTTP response
code. The error message is now set to “OK” to match http.download.
These changes abstract this api from curl and make the focus http.
Cleaned up the code to make it easier to follow and removed some memory
leaks.
http.get and http.download would leak if headers were supplied.
http.get would leak the string buffer if curl_init failed.
All options are now provided via a table which currently supports progress, userpwd, username, password, headers and should be extensible to add more options.
The previous signature of these funtions is supported for backward compatibility.
It appears that there were logic errors in the existing code such that a progress function would have only worked as the last parameter and would not work if headers were supplied. This is fixed such that the old signature will work if progress and headers are supplied.
Moved project definitions from premake.c to premake.h and added PREMAKE_ prefixes.
Utilized PREMAKE_VERSION in the user agent when making curl requests.
The userpwd paramater for http.get and http.download is now correctly optional.
Verified that it doesn't collide with the optional headers parameter to these functions because the type signature is different (headers is passed in as a table).
Added a user agent which is required to interface with GitHub APIs.
http.get and http.download now accept an optional additional parameter which allows specifying the user name and password that will used in the request in the format of username:password.
This utilizes the default authentication of curl which is basic authentication.
This functionality will be utilized for authenticated http retrieval from GitHub APIs.