summaryrefslogtreecommitdiff
path: root/qtart.c
diff options
context:
space:
mode:
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);