diff options
| author | 2023-02-24 09:00:03 +0100 | |
|---|---|---|
| committer | 2023-02-24 09:00:03 +0100 | |
| commit | 1d82d13d620cda7cb51da764c74ca944e9e827e5 (patch) | |
| tree | 930b65f4096d5a73cf1e717c7f98cef8ed0346db | |
| parent | Deleted index_del_md5() and index_del(). (diff) | |
| download | penes-snac2-1d82d13d620cda7cb51da764c74ca944e9e827e5.tar.gz penes-snac2-1d82d13d620cda7cb51da764c74ca944e9e827e5.tar.xz penes-snac2-1d82d13d620cda7cb51da764c74ca944e9e827e5.zip | |
In activitypub_request(), retry failed signed requests as non-signed.
| -rw-r--r-- | activitypub.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/activitypub.c b/activitypub.c index c05c859..cef5c02 100644 --- a/activitypub.c +++ b/activitypub.c | |||
| @@ -55,13 +55,23 @@ int activitypub_request(snac *snac, char *url, d_char **data) | |||
| 55 | int p_size; | 55 | int p_size; |
| 56 | char *ctype; | 56 | char *ctype; |
| 57 | 57 | ||
| 58 | /* check if it's an url for this same site */ | ||
| 59 | /* ... */ | ||
| 60 | |||
| 61 | /* get from the net */ | 58 | /* get from the net */ |
| 62 | response = http_signed_request(snac, "GET", url, | 59 | response = http_signed_request(snac, "GET", url, |
| 63 | NULL, NULL, 0, &status, &payload, &p_size, 0); | 60 | NULL, NULL, 0, &status, &payload, &p_size, 0); |
| 64 | 61 | ||
| 62 | if (status == 0 || (status >= 500 && status <= 599)) { | ||
| 63 | /* I found an instance running Misskey that returned | ||
| 64 | 500 on signed messages but returned the object | ||
| 65 | perfectly without signing (?), so why not try */ | ||
| 66 | xs_free(response); | ||
| 67 | |||
| 68 | xs *hdrs = xs_dict_new(); | ||
| 69 | hdrs = xs_dict_append(hdrs, "accept", "application/activity+json"); | ||
| 70 | |||
| 71 | response = xs_http_request("GET", url, hdrs, | ||
| 72 | NULL, 0, &status, &payload, &p_size, 0); | ||
| 73 | } | ||
| 74 | |||
| 65 | if (valid_status(status)) { | 75 | if (valid_status(status)) { |
| 66 | /* ensure it's ActivityPub data */ | 76 | /* ensure it's ActivityPub data */ |
| 67 | ctype = xs_dict_get(response, "content-type"); | 77 | ctype = xs_dict_get(response, "content-type"); |