diff options
author | Florian Dold <florian@dold.me> | 2024-02-23 15:54:29 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2024-02-26 21:06:41 +0100 |
commit | 47fc98540143afee8f77c6298fdeb3c0b0d7b6ec (patch) | |
tree | 868d9b582cd9745c30161f5e6753c945d8d49333 /qtart.c | |
parent | 0595d6b972a4c3a9f26c93ced206a82a403146de (diff) | |
download | quickjs-tart-47fc98540143afee8f77c6298fdeb3c0b0d7b6ec.tar.gz quickjs-tart-47fc98540143afee8f77c6298fdeb3c0b0d7b6ec.tar.bz2 quickjs-tart-47fc98540143afee8f77c6298fdeb3c0b0d7b6ec.zip |
native http lib interfacedev/dold/native-http
Diffstat (limited to 'qtart.c')
-rw-r--r-- | qtart.c | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -40,6 +40,7 @@ #endif #include "quickjs/cutils.h" +#include "quickjs/quickjs-http.h" #include "tart_module.h" @@ -326,6 +327,7 @@ int main(int argc, char **argv) { JSRuntime *rt; JSContext *ctx; + struct JSHttpClientImplementation *http_impl = NULL; struct trace_malloc_data trace_data = { NULL }; int optind; char *expr = NULL; @@ -459,11 +461,17 @@ int main(int argc, char **argv) js_std_set_worker_new_context_func(JS_NewCustomContext); js_std_init_handlers(rt); ctx = JS_NewCustomContext(rt); - js_os_set_host_message_handler(ctx, handle_host_message, NULL); if (!ctx) { fprintf(stderr, "qjs: cannot allocate JS context\n"); exit(2); } + js_os_set_host_message_handler(ctx, handle_host_message, NULL); + http_impl = js_curl_http_client_create(); + if (!http_impl) { + fprintf(stderr, "qjs: cannot create HTTP client implementation\n"); + exit(2); + } + js_os_set_http_impl(rt, http_impl); /* loader for ES6 modules */ JS_SetModuleLoaderFunc(rt, NULL, js_module_loader, NULL); @@ -518,6 +526,8 @@ int main(int argc, char **argv) } js_std_loop(ctx); } + + fprintf(stderr, "done with main loop\n"); if (dump_memory) { JSMemoryUsage stats; @@ -525,6 +535,7 @@ int main(int argc, char **argv) JS_DumpMemoryUsage(stdout, &stats, rt); } js_std_free_handlers(rt); + js_curl_http_client_destroy(http_impl); JS_FreeContext(ctx); JS_FreeRuntime(rt); |