diff --git a/nginx/ngx_http_js_module.c b/nginx/ngx_http_js_module.c index b50f84a55..87c3fa13b 100644 --- a/nginx/ngx_http_js_module.c +++ b/nginx/ngx_http_js_module.c @@ -276,6 +276,8 @@ static njs_int_t ngx_http_js_server(njs_vm_t *vm, ngx_http_request_t *r, njs_value_t *retval); #if (NJS_HAVE_QUICKJS) +static JSValue ngx_http_qjs_ext_to_string_tag(JSContext *cx, + JSValueConst this_val); static JSValue ngx_http_qjs_ext_args(JSContext *cx, JSValueConst this_val); static JSValue ngx_http_qjs_ext_done(JSContext *cx, JSValueConst this_val, int argc, JSValueConst *argv); @@ -292,6 +294,8 @@ static JSValue ngx_http_qjs_ext_internal_redirect(JSContext *cx, JSValueConst this_val, int argc, JSValueConst *argv); static JSValue ngx_http_qjs_ext_log(JSContext *cx, JSValueConst this_val, int argc, JSValueConst *argv, int level); +static JSValue ngx_http_qjs_ext_periodic_to_string_tag(JSContext *cx, + JSValueConst this_val); static JSValue ngx_http_qjs_ext_periodic_variables(JSContext *cx, JSValueConst this_val, int type); static JSValue ngx_http_qjs_ext_parent(JSContext *cx, JSValueConst this_val); @@ -1030,6 +1034,8 @@ static ngx_http_js_entry_t ngx_http_methods[] = { #if (NJS_HAVE_QUICKJS) static const JSCFunctionListEntry ngx_http_qjs_ext_request[] = { + JS_CGETSET_DEF("[Symbol.toStringTag]", ngx_http_qjs_ext_to_string_tag, + NULL), JS_CGETSET_DEF("args", ngx_http_qjs_ext_args, NULL), JS_CFUNC_DEF("done", 0, ngx_http_qjs_ext_done), JS_CFUNC_MAGIC_DEF("error", 1, ngx_http_qjs_ext_log, NGX_LOG_ERR), @@ -1074,6 +1080,8 @@ static const JSCFunctionListEntry ngx_http_qjs_ext_request[] = { static const JSCFunctionListEntry ngx_http_qjs_ext_periodic[] = { + JS_CGETSET_DEF("[Symbol.toStringTag]", + ngx_http_qjs_ext_periodic_to_string_tag, NULL), JS_CGETSET_MAGIC_DEF("rawVariables", ngx_http_qjs_ext_periodic_variables, NULL, NGX_JS_BUFFER), JS_CGETSET_MAGIC_DEF("variables", ngx_http_qjs_ext_periodic_variables, @@ -4757,6 +4765,14 @@ ngx_http_qjs_query_string_decode(njs_chb_t *chain, const u_char *start, } +static JSValue +ngx_http_qjs_ext_to_string_tag(JSContext *cx, + JSValueConst this_val) +{ + return JS_NewString(cx, "Request"); +} + + static JSValue ngx_http_qjs_ext_args(JSContext *cx, JSValueConst this_val) { @@ -5105,6 +5121,14 @@ ngx_http_qjs_ext_log(JSContext *cx, JSValueConst this_val, int argc, } +static JSValue +ngx_http_qjs_ext_periodic_to_string_tag(JSContext *cx, + JSValueConst this_val) +{ + return JS_NewString(cx, "PeriodicSession"); +} + + static JSValue ngx_http_qjs_ext_periodic_variables(JSContext *cx, JSValueConst this_val, int type) @@ -7378,7 +7402,6 @@ static JSValue ngx_http_qjs_request_make(JSContext *cx, ngx_int_t proto_id, ngx_http_request_t *r) { - int ret; JSValue request; ngx_http_qjs_request_t *req; @@ -7387,12 +7410,6 @@ ngx_http_qjs_request_make(JSContext *cx, ngx_int_t proto_id, return JS_EXCEPTION; } - ret = qjs_set_to_string_tag(cx, request, "Request"); - if (ret == -1) { - JS_FreeValue(cx, request); - return JS_EXCEPTION; - } - req = js_malloc(cx, sizeof(ngx_http_qjs_request_t)); if (req == NULL) { return JS_ThrowOutOfMemory(cx); diff --git a/nginx/ngx_stream_js_module.c b/nginx/ngx_stream_js_module.c index cb5f07cc1..ec6c5e733 100644 --- a/nginx/ngx_stream_js_module.c +++ b/nginx/ngx_stream_js_module.c @@ -145,6 +145,8 @@ static njs_int_t ngx_stream_js_periodic_variables(njs_vm_t *vm, #if (NJS_HAVE_QUICKJS) +static JSValue ngx_stream_qjs_ext_to_string_tag(JSContext *cx, + JSValueConst this_val); static JSValue ngx_stream_qjs_ext_done(JSContext *cx, JSValueConst this_val, int argc, JSValueConst *argv, int magic); static JSValue ngx_stream_qjs_ext_log(JSContext *cx, JSValueConst this_val, @@ -153,6 +155,8 @@ static JSValue ngx_stream_qjs_ext_on(JSContext *cx, JSValueConst this_val, int argc, JSValueConst *argv); static JSValue ngx_stream_qjs_ext_off(JSContext *cx, JSValueConst this_val, int argc, JSValueConst *argv); +static JSValue ngx_stream_qjs_ext_periodic_to_string_tag(JSContext *cx, + JSValueConst this_val); static JSValue ngx_stream_qjs_ext_periodic_variables(JSContext *cx, JSValueConst this_val, int type); static JSValue ngx_stream_qjs_ext_remote_address(JSContext *cx, @@ -757,6 +761,8 @@ njs_module_t *njs_stream_js_addon_modules[] = { #if (NJS_HAVE_QUICKJS) static const JSCFunctionListEntry ngx_stream_qjs_ext_session[] = { + JS_CGETSET_DEF("[Symbol.toStringTag]", ngx_stream_qjs_ext_to_string_tag, + NULL), JS_CFUNC_MAGIC_DEF("allow", 1, ngx_stream_qjs_ext_done, NGX_OK), JS_CFUNC_MAGIC_DEF("decline", 1, ngx_stream_qjs_ext_done, -NGX_DECLINED), JS_CFUNC_MAGIC_DEF("deny", 1, ngx_stream_qjs_ext_done, -NGX_DONE), @@ -783,6 +789,8 @@ static const JSCFunctionListEntry ngx_stream_qjs_ext_session[] = { static const JSCFunctionListEntry ngx_stream_qjs_ext_periodic[] = { + JS_CGETSET_DEF("[Symbol.toStringTag]", + ngx_stream_qjs_ext_periodic_to_string_tag, NULL), JS_CGETSET_MAGIC_DEF("rawVariables", ngx_stream_qjs_ext_periodic_variables, NULL, NGX_JS_BUFFER), JS_CGETSET_MAGIC_DEF("variables", ngx_stream_qjs_ext_periodic_variables, @@ -1963,6 +1971,13 @@ ngx_engine_njs_clone(ngx_js_ctx_t *ctx, ngx_js_loc_conf_t *cf, #if (NJS_HAVE_QUICKJS) +static JSValue +ngx_stream_qjs_ext_to_string_tag(JSContext *cx, JSValueConst this_val) +{ + return JS_NewString(cx, "Stream Session"); +} + + static JSValue ngx_stream_qjs_ext_done(JSContext *cx, JSValueConst this_val, int argc, JSValueConst *argv, int magic) @@ -2180,6 +2195,14 @@ ngx_stream_qjs_ext_off(JSContext *cx, JSValueConst this_val, int argc, } +static JSValue +ngx_stream_qjs_ext_periodic_to_string_tag(JSContext *cx, + JSValueConst this_val) +{ + return JS_NewString(cx, "PeriodicSession"); +} + + static JSValue ngx_stream_qjs_ext_periodic_variables(JSContext *cx, JSValueConst this_val, int type) @@ -2691,7 +2714,6 @@ static JSValue ngx_stream_qjs_session_make(JSContext *cx, ngx_int_t proto_id, ngx_stream_session_t *s) { - int ret; JSValue session; ngx_uint_t i; ngx_stream_qjs_session_t *ses; @@ -2701,12 +2723,6 @@ ngx_stream_qjs_session_make(JSContext *cx, ngx_int_t proto_id, return JS_EXCEPTION; } - ret = qjs_set_to_string_tag(cx, session, "Stream Session"); - if (ret == -1) { - JS_FreeValue(cx, session); - return JS_EXCEPTION; - } - ses = js_malloc(cx, sizeof(ngx_stream_qjs_session_t)); if (ses == NULL) { return JS_ThrowOutOfMemory(cx);