Don't URL encode payloads anymore

This commit is contained in:
9pfs 2024-04-24 01:00:23 +00:00
parent 50b5fb5a34
commit 4e17e2ddd5
Signed by: 9pfs
SSH key fingerprint: SHA256:TOcGxMQCfy4VvRM8AzgXErKXdkAtaTcpGXgYMpyoJoY

View file

@ -5,6 +5,8 @@
#include <string.h>
#include <assert.h>
#define NOTIFICATION_PREFIX "[h/nest-sanity-checks] "
/* No longer URL encoding payloads. TODO: remove later */
#pragma GCC poison urlencoded_report
/* #define NOTIFICATION_PREFIX_LEN sizeof(NOTIFICATION_PREFIX) */
/* notify_init() initializes curl.
If this fails, exiting is the only option, as curl must be usable,
@ -71,17 +73,10 @@ int send_alarm(const char *report) {
const char *prefixed_report;
prefixed_report = build_prefixed_report(report);
assert(prefixed_report!=NULL);
const char *urlencoded_report;
urlencoded_report = curl_easy_escape(curl, prefixed_report, 0);
/* assert(urlencoded_report!=NULL); */
if(urlencoded_report == NULL) {
fprintf(stderr, "[E] Failed to send report, curl_easy_escape failed.\n");
return -1;
}
CURLcode post_field_set_result;
post_field_set_result = curl_easy_setopt(curl, CURLOPT_POSTFIELDS, urlencoded_report);
post_field_set_result = curl_easy_setopt(curl, CURLOPT_POSTFIELDS, prefixed_report);
if(post_field_set_result != CURLE_OK) {
fprintf(stderr, "[E] Failed to send report, setting CURLOPT_POSTFIELDS to %s failed.\n", urlencoded_report);
fprintf(stderr, "[E] Failed to send report, setting CURLOPT_POSTFIELDS to %s failed.\n", prefixed_report);
return -1;
}
CURLcode res;