summaryrefslogtreecommitdiff
path: root/xs_curl.h
diff options
context:
space:
mode:
authorGravatar default2023-08-09 15:54:36 +0200
committerGravatar default2023-08-09 15:54:36 +0200
commit912cfb5aaa915829efe92cc34ad7ad888e93c14a (patch)
tree350744e7907f318c8dac42dc72cc9940a2f9ed74 /xs_curl.h
parentRevert "Implemented hide_followers_only." (diff)
downloadpenes-snac2-912cfb5aaa915829efe92cc34ad7ad888e93c14a.tar.gz
penes-snac2-912cfb5aaa915829efe92cc34ad7ad888e93c14a.tar.xz
penes-snac2-912cfb5aaa915829efe92cc34ad7ad888e93c14a.zip
Backport from xs.
Diffstat (limited to 'xs_curl.h')
-rw-r--r--xs_curl.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/xs_curl.h b/xs_curl.h
index dbc1325..9f9b63b 100644
--- a/xs_curl.h
+++ b/xs_curl.h
@@ -96,7 +96,7 @@ xs_dict *xs_http_request(const char *method, const char *url,
96 xs_dict *p; 96 xs_dict *p;
97 xs_str *k; 97 xs_str *k;
98 xs_val *v; 98 xs_val *v;
99 long lstatus; 99 long lstatus = 0;
100 struct _payload_data pd; 100 struct _payload_data pd;
101 101
102 response = xs_dict_new(); 102 response = xs_dict_new();
@@ -160,7 +160,7 @@ xs_dict *xs_http_request(const char *method, const char *url,
160 curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list); 160 curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list);
161 161
162 /* do it */ 162 /* do it */
163 curl_easy_perform(curl); 163 CURLcode cc = curl_easy_perform(curl);
164 164
165 curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &lstatus); 165 curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &lstatus);
166 166
@@ -168,8 +168,12 @@ xs_dict *xs_http_request(const char *method, const char *url,
168 168
169 curl_slist_free_all(list); 169 curl_slist_free_all(list);
170 170
171 if (status != NULL) 171 if (status != NULL) {
172 if (lstatus == 0)
173 lstatus = -cc;
174
172 *status = (int) lstatus; 175 *status = (int) lstatus;
176 }
173 177
174 if (p_size != NULL) 178 if (p_size != NULL)
175 *p_size = ipd.size; 179 *p_size = ipd.size;