diff options
| author | 2025-10-14 05:21:33 +0200 | |
|---|---|---|
| committer | 2025-10-14 05:21:33 +0200 | |
| commit | 5bf3133f9173464ae2a29ad9bbb9c3cb46468441 (patch) | |
| tree | 9b0f5b92691fedb370e4c32c70c88c42abe337f0 /xs_webmention.h | |
| parent | Updated RELEASE_NOTES. (diff) | |
| download | snac2-5bf3133f9173464ae2a29ad9bbb9c3cb46468441.tar.gz snac2-5bf3133f9173464ae2a29ad9bbb9c3cb46468441.tar.xz snac2-5bf3133f9173464ae2a29ad9bbb9c3cb46468441.zip | |
xs_webmention.h: updated.
Diffstat (limited to 'xs_webmention.h')
| -rw-r--r-- | xs_webmention.h | 10 |
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_ | |||
| 10 | 10 | ||
| 11 | #ifdef XS_IMPLEMENTATION | 11 | #ifdef XS_IMPLEMENTATION |
| 12 | 12 | ||
| 13 | #include "xs_http.h" | ||
| 14 | |||
| 13 | int xs_webmention_send(const char *source, const char *target, const char *user_agent) | 15 | int xs_webmention_send(const char *source, const char *target, const char *user_agent) |
| 14 | /* sends a Webmention to target. | 16 | /* sends a Webmention to target. |
| 15 | Returns: < 0, error; 0, no Webmention endpoint; > 0, Webmention sent */ | 17 | 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_ | |||
| 29 | h_req = xs_http_request("HEAD", target, headers, NULL, 0, &status, NULL, &p_size, 0); | 31 | h_req = xs_http_request("HEAD", target, headers, NULL, 0, &status, NULL, &p_size, 0); |
| 30 | 32 | ||
| 31 | /* return immediate failures */ | 33 | /* return immediate failures */ |
| 32 | if (status < 200 || status > 299) | 34 | if (!xs_http_valid_status(status)) |
| 33 | return -1; | 35 | return -1; |
| 34 | 36 | ||
| 35 | const char *link = xs_dict_get(h_req, "link"); | 37 | 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_ | |||
| 51 | 53 | ||
| 52 | g_req = xs_http_request("GET", target, headers, NULL, 0, &status, &payload, &p_size, 0); | 54 | g_req = xs_http_request("GET", target, headers, NULL, 0, &status, &payload, &p_size, 0); |
| 53 | 55 | ||
| 54 | if (status < 200 || status > 299) | 56 | if (!xs_http_valid_status(status)) |
| 55 | return -1; | 57 | return -1; |
| 56 | 58 | ||
| 57 | const char *ctype = xs_dict_get(g_req, "content-type"); | 59 | 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_ | |||
| 107 | 109 | ||
| 108 | xs *rsp = xs_http_request("POST", endpoint, headers, body, strlen(body), &status, NULL, 0, 0); | 110 | xs *rsp = xs_http_request("POST", endpoint, headers, body, strlen(body), &status, NULL, 0, 0); |
| 109 | 111 | ||
| 110 | if (status < 200 || status > 299) | 112 | if (!xs_http_valid_status(status)) |
| 111 | status = -4; | 113 | status = -4; |
| 112 | else | 114 | else |
| 113 | status = 1; | 115 | status = 1; |
| @@ -136,7 +138,7 @@ int xs_webmention_hook(const char *source, const char *target, const char *user_ | |||
| 136 | 138 | ||
| 137 | g_req = xs_http_request("GET", source, headers, NULL, 0, &status, &payload, &p_size, 0); | 139 | g_req = xs_http_request("GET", source, headers, NULL, 0, &status, &payload, &p_size, 0); |
| 138 | 140 | ||
| 139 | if (status < 200 || status > 299) | 141 | if (!xs_http_valid_status(status)) |
| 140 | return -1; | 142 | return -1; |
| 141 | 143 | ||
| 142 | if (!xs_is_string(payload)) | 144 | if (!xs_is_string(payload)) |