-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttps_samp.inc
More file actions
89 lines (72 loc) · 2.36 KB
/
Copy pathhttps_samp.inc
File metadata and controls
89 lines (72 loc) · 2.36 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
* https_samp v1.0.0 - HTTPS client plugin for SA-MP and Open Multiplayer.
* Author: NullSablex
* Repository: https://github.com/NullSablex/https_samp
* License: AGPL-3.0-or-later
*/
#if defined _https_samp_included
#endinput
#endif
#define _https_samp_included
#define HTTPS_SAMP_VERSION "1.0.0"
#pragma library https
// Request types
enum {
HTTPS_GET = 1,
HTTPS_POST,
HTTPS_HEAD,
HTTPS_PUT,
HTTPS_DELETE,
HTTPS_PATCH,
}
// Error codes
enum {
HTTPS_ERROR_NONE = 0,
HTTPS_ERROR_BAD_URL,
HTTPS_ERROR_TLS_HANDSHAKE,
HTTPS_ERROR_NO_SOCKET,
HTTPS_ERROR_CANT_CONNECT,
HTTPS_ERROR_SEND_FAIL,
HTTPS_ERROR_CONTENT_TOO_BIG,
HTTPS_ERROR_TIMEOUT,
HTTPS_ERROR_POLICY_BLOCKED,
HTTPS_ERROR_UNKNOWN = 10,
}
// Request
native https(index, type, const url[], const data[], const callback[]);
// Cancellation
native bool:https_cancel(index);
// Request headers
native bool:https_set_header(const key[], const value[]);
native bool:https_set_global_header(const key[], const value[]);
native bool:https_clear_global_headers();
// Response headers (call inside the request callback)
native bool:https_response_header(const key[], dest[], max_len = sizeof(dest));
// Body builders (one-shot, consumed by the next POST/PUT/PATCH)
native bool:https_bodyf(const data[]);
native bool:https_jsonf(const data[]);
native bool:https_form_add(const key[], const value[]);
native bool:https_multipart_add_text(const key[], const value[]);
native bool:https_multipart_add_file(const field[], const filename[], const path[]);
// Authentication helpers (one-shot)
native bool:https_set_basic_auth_once(const user[], const password[]);
native bool:https_set_bearer_once(const token[]);
// Queue
// Kept for backwards compatibility only: since rust-samp v3.0.0 the unified
// on_tick already dispatches callbacks automatically on SA-MP and native open.mp.
native https_process_queue();
native https_queue_len();
// Limits
native https_set_max_body_bytes(bytes);
native https_get_max_body_bytes();
// Timeouts
native bool:https_set_timeout_once(total_ms);
// Security
native bool:https_allow_cross_host_once(bool:enable);
// Cookies
native bool:https_cookies_enable(bool:enable);
native bool:https_cookies_clear();
// mTLS
native bool:https_mtls_set_pem(const pem[]);
native bool:https_mtls_set_pem_file(const path[]);
native bool:https_mtls_clear();