commit ff95618

grunfink  ·  2026-09-29 06:32:12 +0000 UTC
parent 8f6b982
New knobs xs_curl_force_http1 and xs_curl_force_ipv6.
1 files changed,  +15, -4
+15, -4
 1@@ -15,10 +15,16 @@ int xs_smtp_request(const char *url, const char *user, const char *pass,
 2 
 3 const char *xs_curl_strerr(int errnum);
 4 
 5+extern int xs_curl_force_http1;
 6+extern int xs_curl_force_ipv6;
 7+
 8 #ifdef XS_IMPLEMENTATION
 9 
10 #include <curl/curl.h>
11 
12+int xs_curl_force_http1 = 0;
13+int xs_curl_force_ipv6 = 0;
14+
15 static size_t _header_callback(char *buffer, size_t size,
16                                size_t nitems, xs_dict **userdata)
17 {
18@@ -115,10 +121,15 @@ xs_dict *xs_http_request(const char *method, const char *url,
19 
20     curl_easy_setopt(curl, CURLOPT_TIMEOUT, (long) timeout);
21 
22-#ifdef FORCE_HTTP_1_1
23-    /* force HTTP/1.1 */
24-    curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
25-#endif
26+    if (xs_curl_force_http1) {
27+        /* force HTTP/1.1 */
28+        curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
29+    }
30+
31+    if (xs_curl_force_ipv6) {
32+        /* force IPv6 */
33+        curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V6);
34+    }
35 
36     /* obey redirections */
37     curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);