aboutsummaryrefslogtreecommitdiff
path: root/xs_webmention.h
diff options
context:
space:
mode:
authorgrunfink <grunfink@comam.es>2025-10-14 05:21:33 +0200
committergrunfink <grunfink@comam.es>2025-10-14 05:21:33 +0200
commit5bf3133f9173464ae2a29ad9bbb9c3cb46468441 (patch)
tree9b0f5b92691fedb370e4c32c70c88c42abe337f0 /xs_webmention.h
parent9e6d583a4fccd6150a9cd2c5ea32ef16cfa0516e (diff)
xs_webmention.h: updated.
Diffstat (limited to 'xs_webmention.h')
-rw-r--r--xs_webmention.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/xs_webmention.h b/xs_webmention.h
index e177573..f9578b4 100644
--- a/xs_webmention.h
+++ b/xs_webmention.h
@@ -10,6 +10,8 @@ int xs_webmention_hook(const char *source, const char *target, const char *user_
#ifdef XS_IMPLEMENTATION
+#include "xs_http.h"
+
int xs_webmention_send(const char *source, const char *target, const char *user_agent)
/* sends a Webmention to target.
Returns: < 0, error; 0, no Webmention endpoint; > 0, Webmention sent */
@@ -29,7 +31,7 @@ int xs_webmention_send(const char *source, const char *target, const char *user_
h_req = xs_http_request("HEAD", target, headers, NULL, 0, &status, NULL, &p_size, 0);
/* return immediate failures */
- if (status < 200 || status > 299)
+ if (!xs_http_valid_status(status))
return -1;
const char *link = xs_dict_get(h_req, "link");
@@ -51,7 +53,7 @@ int xs_webmention_send(const char *source, const char *target, const char *user_
g_req = xs_http_request("GET", target, headers, NULL, 0, &status, &payload, &p_size, 0);
- if (status < 200 || status > 299)
+ if (!xs_http_valid_status(status))
return -1;
const char *ctype = xs_dict_get(g_req, "content-type");
@@ -107,7 +109,7 @@ int xs_webmention_send(const char *source, const char *target, const char *user_
xs *rsp = xs_http_request("POST", endpoint, headers, body, strlen(body), &status, NULL, 0, 0);
- if (status < 200 || status > 299)
+ if (!xs_http_valid_status(status))
status = -4;
else
status = 1;
@@ -136,7 +138,7 @@ int xs_webmention_hook(const char *source, const char *target, const char *user_
g_req = xs_http_request("GET", source, headers, NULL, 0, &status, &payload, &p_size, 0);
- if (status < 200 || status > 299)
+ if (!xs_http_valid_status(status))
return -1;
if (!xs_is_string(payload))