Skip to content

Commit e61a198

Browse files
committed
Fetch: QuickJS support.
1 parent 14f8d04 commit e61a198

19 files changed

+2581
-22
lines changed

nginx/config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ NJS_ENGINE_LIB="$ngx_addon_dir/../build/libnjs.a"
156156
if [ "$NJS_HAVE_QUICKJS" = "YES" ]; then
157157
NJS_ENGINE_DEP="$ngx_addon_dir/../build/libqjs.a"
158158
NJS_ENGINE_LIB="$ngx_addon_dir/../build/libnjs.a $ngx_addon_dir/../build/libqjs.a"
159+
QJS_SRCS="$QJS_SRCS $ngx_addon_dir/ngx_qjs_fetch.c"
159160
fi
160161

161162
if [ $HTTP != NO ]; then

nginx/ngx_http_js_module.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,6 +1134,9 @@ static JSClassDef ngx_http_qjs_headers_out_class = {
11341134
qjs_module_t *njs_http_qjs_addon_modules[] = {
11351135
&ngx_qjs_ngx_module,
11361136
&ngx_qjs_ngx_shared_dict_module,
1137+
#ifdef NJS_HAVE_QUICKJS
1138+
&ngx_qjs_ngx_fetch_module,
1139+
#endif
11371140
/*
11381141
* Shared addons should be in the same order and the same positions
11391142
* in all nginx modules.

nginx/ngx_js.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ static const JSCFunctionListEntry ngx_qjs_ext_ngx[] = {
441441
JS_CGETSET_MAGIC_DEF("ERR", ngx_qjs_ext_constant_integer, NULL,
442442
NGX_LOG_ERR),
443443
JS_CGETSET_DEF("error_log_path", ngx_qjs_ext_error_log_path, NULL),
444+
JS_CFUNC_DEF("fetch", 2, ngx_qjs_ext_fetch),
444445
JS_CGETSET_MAGIC_DEF("INFO", ngx_qjs_ext_constant_integer, NULL,
445446
NGX_LOG_INFO),
446447
JS_CFUNC_MAGIC_DEF("log", 1, ngx_qjs_ext_log, 0),

nginx/ngx_js.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@
6363
#define NGX_QJS_CLASS_ID_SHARED (NGX_QJS_CLASS_ID_OFFSET + 11)
6464
#define NGX_QJS_CLASS_ID_SHARED_DICT (NGX_QJS_CLASS_ID_OFFSET + 12)
6565
#define NGX_QJS_CLASS_ID_SHARED_DICT_ERROR (NGX_QJS_CLASS_ID_OFFSET + 13)
66+
#define NGX_QJS_CLASS_ID_FETCH_HEADERS (NGX_QJS_CLASS_ID_OFFSET + 14)
67+
#define NGX_QJS_CLASS_ID_FETCH_REQUEST (NGX_QJS_CLASS_ID_OFFSET + 15)
68+
#define NGX_QJS_CLASS_ID_FETCH_RESPONSE (NGX_QJS_CLASS_ID_OFFSET + 16)
6669

6770

6871
typedef struct ngx_js_loc_conf_s ngx_js_loc_conf_t;
@@ -346,6 +349,9 @@ ngx_int_t ngx_qjs_exception(ngx_engine_t *e, ngx_str_t *s);
346349
ngx_int_t ngx_qjs_integer(JSContext *cx, JSValueConst val, ngx_int_t *n);
347350
ngx_int_t ngx_qjs_string(JSContext *cx, JSValueConst val, ngx_str_t *str);
348351

352+
JSValue ngx_qjs_ext_fetch(JSContext *cx, JSValueConst this_val, int argc,
353+
JSValueConst *argv);
354+
349355
#define ngx_qjs_prop(cx, type, start, len) \
350356
((type == NGX_JS_STRING) ? qjs_string_create(cx, start, len) \
351357
: qjs_buffer_create(cx, (u_char *) start, len))
@@ -382,6 +388,7 @@ extern qjs_module_t qjs_xml_module;
382388
extern qjs_module_t qjs_zlib_module;
383389
extern qjs_module_t ngx_qjs_ngx_module;
384390
extern qjs_module_t ngx_qjs_ngx_shared_dict_module;
391+
extern qjs_module_t ngx_qjs_ngx_fetch_module;
385392

386393
#endif
387394

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy