diff options
| author | 2023-08-09 15:54:36 +0200 | |
|---|---|---|
| committer | 2023-08-09 15:54:36 +0200 | |
| commit | 912cfb5aaa915829efe92cc34ad7ad888e93c14a (patch) | |
| tree | 350744e7907f318c8dac42dc72cc9940a2f9ed74 /xs_curl.h | |
| parent | Revert "Implemented hide_followers_only." (diff) | |
| download | penes-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.h | 10 |
1 files changed, 7 insertions, 3 deletions
| @@ -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; |