-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresponse-headers.pwn
More file actions
36 lines (32 loc) · 933 Bytes
/
response-headers.pwn
File metadata and controls
36 lines (32 loc) · 933 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// response-headers.pwn — read response headers inside the callback.
//
// Demonstrates:
// * Using https_response_header from inside the callback.
// * Reading common headers (rate-limit, ETag).
#include <a_samp>
#include <https_samp>
public OnGameModeInit()
{
https(1, HTTPS_GET, "https://api.github.com/zen", "", "OnZen");
return 1;
}
forward OnZen(index, response[], status, error);
public OnZen(index, response[], status, error)
{
if (error != HTTPS_ERROR_NONE)
{
printf("[example] zen failed: error=%d", error);
return 1;
}
new etag[128], remaining[16];
if (https_response_header("ETag", etag))
{
printf("[example] etag: %s", etag);
}
if (https_response_header("X-RateLimit-Remaining", remaining))
{
printf("[example] rate-limit remaining: %s", remaining);
}
printf("[example] status=%d body=%s", status, response);
return 1;
}