Dmitry Volyntsev
August 25, 2022 08:50PM
details: https://hg.nginx.org/njs/rev/43b31a943c08
branches:
changeset: 1935:43b31a943c08
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Thu Aug 25 16:57:28 2022 -0700
description:
HTTP: added r.internal property.

diffstat:

nginx/ngx_http_js_module.c | 30 ++++++++++++++++++++++++++++++
1 files changed, 30 insertions(+), 0 deletions(-)

diffs (54 lines):

diff -r e023db05004f -r 43b31a943c08 nginx/ngx_http_js_module.c
--- a/nginx/ngx_http_js_module.c Wed Aug 24 17:04:58 2022 -0700
+++ b/nginx/ngx_http_js_module.c Thu Aug 25 16:57:28 2022 -0700
@@ -174,6 +174,9 @@ static njs_int_t ngx_http_js_ext_interna
static njs_int_t ngx_http_js_ext_get_http_version(njs_vm_t *vm,
njs_object_prop_t *prop, njs_value_t *value, njs_value_t *setval,
njs_value_t *retval);
+static njs_int_t ngx_http_js_ext_internal(njs_vm_t *vm,
+ njs_object_prop_t *prop, njs_value_t *value, njs_value_t *setval,
+ njs_value_t *retval);
static njs_int_t ngx_http_js_ext_get_remote_address(njs_vm_t *vm,
njs_object_prop_t *prop, njs_value_t *value, njs_value_t *setval,
njs_value_t *retval);
@@ -534,6 +537,15 @@ static njs_external_t ngx_http_js_ext_r
},

{
+ .flags = NJS_EXTERN_PROPERTY,
+ .name.string = njs_str("internal"),
+ .enumerable = 1,
+ .u.property = {
+ .handler = ngx_http_js_ext_internal,
+ }
+ },
+
+ {
.flags = NJS_EXTERN_METHOD,
.name.string = njs_str("internalRedirect"),
.writable = 1,
@@ -2504,6 +2516,24 @@ ngx_http_js_ext_get_http_version(njs_vm_


static njs_int_t
+ngx_http_js_ext_internal(njs_vm_t *vm, njs_object_prop_t *prop,
+ njs_value_t *value, njs_value_t *setval, njs_value_t *retval)
+{
+ ngx_http_request_t *r;
+
+ r = njs_vm_external(vm, ngx_http_js_request_proto_id, value);
+ if (r == NULL) {
+ njs_value_undefined_set(retval);
+ return NJS_DECLINED;
+ }
+
+ njs_value_boolean_set(retval, r->internal);
+
+ return NJS_OK;
+}
+
+
+static njs_int_t
ngx_http_js_ext_get_remote_address(njs_vm_t *vm, njs_object_prop_t *prop,
njs_value_t *value, njs_value_t *setval, njs_value_t *retval)
{
_______________________________________________
nginx-devel mailing list -- nginx-devel@nginx.org
To unsubscribe send an email to nginx-devel-leave@nginx.org
Subject Author Views Posted

[njs] HTTP: added r.internal property.

Dmitry Volyntsev 451 August 25, 2022 08:50PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 205
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready