summaryrefslogtreecommitdiff
path: root/qtart.c
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2024-02-23 15:54:29 +0100
committerFlorian Dold <florian@dold.me>2024-02-26 21:06:41 +0100
commit47fc98540143afee8f77c6298fdeb3c0b0d7b6ec (patch)
tree868d9b582cd9745c30161f5e6753c945d8d49333 /qtart.c
parent0595d6b972a4c3a9f26c93ced206a82a403146de (diff)
downloadquickjs-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.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/qtart.c b/qtart.c
index cabde5a..0d2ab65 100644
--- a/qtart.c
+++ b/qtart.c
@@ -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);