summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordefault <nobody@localhost>2023-08-09 15:54:36 +0200
committerdefault <nobody@localhost>2023-08-09 15:54:36 +0200
commit912cfb5aaa915829efe92cc34ad7ad888e93c14a (patch)
tree350744e7907f318c8dac42dc72cc9940a2f9ed74
parent18976dc6b8c1ee65056444fa6ac8b11541caa5dd (diff)
Backport from xs.
-rw-r--r--xs_curl.h10
-rw-r--r--xs_json.h5
-rw-r--r--xs_version.h2
3 files changed, 10 insertions, 7 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,
xs_dict *p;
xs_str *k;
xs_val *v;
- long lstatus;
+ long lstatus = 0;
struct _payload_data pd;
response = xs_dict_new();
@@ -160,7 +160,7 @@ xs_dict *xs_http_request(const char *method, const char *url,
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list);
/* do it */
- curl_easy_perform(curl);
+ CURLcode cc = curl_easy_perform(curl);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &lstatus);
@@ -168,8 +168,12 @@ xs_dict *xs_http_request(const char *method, const char *url,
curl_slist_free_all(list);
- if (status != NULL)
+ if (status != NULL) {
+ if (lstatus == 0)
+ lstatus = -cc;
+
*status = (int) lstatus;
+ }
if (p_size != NULL)
*p_size = ipd.size;
diff --git a/xs_json.h b/xs_json.h
index b8b6b3a..368e5d6 100644
--- a/xs_json.h
+++ b/xs_json.h
@@ -189,8 +189,7 @@ typedef enum {
JS_COLON,
JS_VALUE,
JS_STRING,
- JS_INTEGER,
- JS_REAL,
+ JS_NUMBER,
JS_TRUE,
JS_FALSE,
JS_NULL,
@@ -287,7 +286,7 @@ static xs_val *_xs_json_load_lexer(FILE *f, js_type *t)
ungetc(c, f);
if (fscanf(f, "%lf", &d) == 1) {
- *t = JS_REAL;
+ *t = JS_NUMBER;
v = xs_number_new(d);
}
}
diff --git a/xs_version.h b/xs_version.h
index 5131181..7da6c06 100644
--- a/xs_version.h
+++ b/xs_version.h
@@ -1 +1 @@
-/* 4d883b5331e9275f2439b0983a0f978d1cd21e11 */
+/* ac9fa6f1941aa3e701bbb1da50b4d5a07090eddb */