allow POST requests to be received from ACLK (#16770)
Costa Tsaousis committed
Jan 12, 2024 at 14:55 UTC
ab576694f7acbaaa01023a49eb00af591660e051
1 file changed
+8
-5
aclk/aclk_rx_msgs.c
+8
-5
@@ -11,7 +11,6 @@
11
#include "schema-wrappers/proto_2_json.h"
12
13
#define ACLK_V2_PAYLOAD_SEPARATOR "\x0D\x0A\x0D\x0A"
14
-#define ACLK_CLOUD_REQ_V2_PREFIX "GET /"
14
15
#define ACLK_V_COMPRESSION 2
16
@@ -100,13 +99,17 @@ static inline int aclk_v2_payload_get_query(const char *payload, char **query_ur
99
{
100
const char *start, *end;
101
103
- // TODO better check of URL
104
- if(strncmp(payload, ACLK_CLOUD_REQ_V2_PREFIX, strlen(ACLK_CLOUD_REQ_V2_PREFIX)) != 0) {
102
+ if(strncmp(payload, "GET /", 5) == 0 || strncmp(payload, "PUT /", 5) == 0)
103
+ start = payload + 4;
104
+ else if(strncmp(payload, "POST /", 6) == 0)
105
+ start = payload + 5;
106
+ else if(strncmp(payload, "DELETE /", 8) == 0)
107
+ start = payload + 7;
108
+ else {
109
errno = 0;
106
- netdata_log_error("Only accepting requests that start with \"%s\" from CLOUD.", ACLK_CLOUD_REQ_V2_PREFIX);
110
+ netdata_log_error("Only accepting requests that start with GET, POST, PUT, DELETE from CLOUD.");
111
return 1;
112
}
109
- start = payload + 4;
113
114
if(!(end = strstr(payload, HTTP_1_1 HTTP_ENDL))) {
115
errno = 0;