Skip to content

Latest commit

 

History

History
75 lines (57 loc) · 1.57 KB

http.md

File metadata and controls

75 lines (57 loc) · 1.57 KB

HTTP

WARNING: Requests are not thread safe. Use critical sections when needed

Example

critical_enter("http");

json = "{\"login\":\"login\",\"password\":\"password\"}";
url = "http://httpbin.org/post";

request = HTTP_Init();
CURL_AddHeader(request, "Accept: application/json,Content-Type: application/json");
HTTP_Post(request, json, url);
status = AsyncWait(request);

response = HTTP_Response(request);
HTTP_Free(request);

critical_leave("http");

The example above use GSC functions defined in Critical Sections

HTTP_Init()

Initialize an HTTP request. The request should be freed when done using HTTP_Free.

request = HTTP_Init();

HTTP_Free(<request>)

Free the HTTP request.

HTTP_Free(request);

HTTP_GetFile(<request>, <filepath>, <url>)

Save a file from HTTP url.

request = HTTP_Init();
HTTP_GetFile(request, "test/version.txt", "https://iswenzz.com:1337/speedrun_app/version.txt");

HTTP_PostFile(<request>, <filepath>, <url>)

Upload a file to HTTP url.

request = HTTP_Init();
HTTP_PostFile(request, "test/version.txt", "http://httpbin.org/post");

HTTP_Get(<request>, <url>)

Get a string from HTTP url.

request = HTTP_Init();
HTTP_Get(request, "http://httpbin.org/get");

HTTP_Post(<request>, <string>, <url>)

Post a string to HTTP url.

request = HTTP_Init();
HTTP_Post(request, "{\"login\":\"login\",\"password\":\"password\"}", "http://httpbin.org/post");