commit 912cfb5

default  ·  2023-08-09 13:54:36 +0000 UTC
parent 18976dc
Backport from xs.
3 files changed,  +10, -7
+7, -3
 1@@ -96,7 +96,7 @@ xs_dict *xs_http_request(const char *method, const char *url,
 2     xs_dict *p;
 3     xs_str *k;
 4     xs_val *v;
 5-    long lstatus;
 6+    long lstatus = 0;
 7     struct _payload_data pd;
 8 
 9     response = xs_dict_new();
10@@ -160,7 +160,7 @@ xs_dict *xs_http_request(const char *method, const char *url,
11     curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list);
12 
13     /* do it */
14-    curl_easy_perform(curl);
15+    CURLcode cc = curl_easy_perform(curl);
16 
17     curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &lstatus);
18 
19@@ -168,8 +168,12 @@ xs_dict *xs_http_request(const char *method, const char *url,
20 
21     curl_slist_free_all(list);
22 
23-    if (status != NULL)
24+    if (status != NULL) {
25+        if (lstatus == 0)
26+            lstatus = -cc;
27+
28         *status = (int) lstatus;
29+    }
30 
31     if (p_size != NULL)
32         *p_size = ipd.size;
+2, -3
 1@@ -189,8 +189,7 @@ typedef enum {
 2     JS_COLON,
 3     JS_VALUE,
 4     JS_STRING,
 5-    JS_INTEGER,
 6-    JS_REAL,
 7+    JS_NUMBER,
 8     JS_TRUE,
 9     JS_FALSE,
10     JS_NULL,
11@@ -287,7 +286,7 @@ static xs_val *_xs_json_load_lexer(FILE *f, js_type *t)
12 
13         ungetc(c, f);
14         if (fscanf(f, "%lf", &d) == 1) {
15-            *t = JS_REAL;
16+            *t = JS_NUMBER;
17             v = xs_number_new(d);
18         }
19     }
+1, -1
1@@ -1 +1 @@
2-/* 4d883b5331e9275f2439b0983a0f978d1cd21e11 */
3+/* ac9fa6f1941aa3e701bbb1da50b4d5a07090eddb */