[njs] http req.response() method.

Dmitry Volyntsev xeioex at nginx.com
Wed Mar 21 14:33:27 UTC 2018


details:   http://hg.nginx.org/njs/rev/fa22235730b1
branches:  
changeset: 464:fa22235730b1
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Wed Mar 21 17:33:12 2018 +0300
description:
http req.response() method.

diffstat:

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

diffs (55 lines):

diff -r 6d599ae5b35b -r fa22235730b1 nginx/ngx_http_js_module.c
--- a/nginx/ngx_http_js_module.c	Wed Mar 21 17:33:12 2018 +0300
+++ b/nginx/ngx_http_js_module.c	Wed Mar 21 17:33:12 2018 +0300
@@ -105,6 +105,8 @@ static njs_ret_t ngx_http_js_ext_next_ar
     void *obj, void *next);
 static njs_ret_t ngx_http_js_ext_get_variable(njs_vm_t *vm, njs_value_t *value,
     void *obj, uintptr_t data);
+static njs_ret_t ngx_http_js_ext_get_response(njs_vm_t *vm, njs_value_t *value,
+    void *obj, uintptr_t data);
 
 static njs_host_event_t ngx_http_js_set_timer(njs_external_ptr_t external,
     uint64_t delay, njs_vm_event_t vm_event);
@@ -367,6 +369,18 @@ static njs_external_t  ngx_http_js_ext_r
       NULL,
       NULL,
       0 },
+
+    { nxt_string("response"),
+      NJS_EXTERN_PROPERTY,
+      NULL,
+      0,
+      ngx_http_js_ext_get_response,
+      NULL,
+      NULL,
+      NULL,
+      NULL,
+      NULL,
+      0 },
 };
 
 
@@ -1293,6 +1307,23 @@ ngx_http_js_ext_get_variable(njs_vm_t *v
 }
 
 
+static njs_ret_t
+ngx_http_js_ext_get_response(njs_vm_t *vm, njs_value_t *value, void *obj,
+    uintptr_t data)
+{
+    ngx_http_js_ctx_t   *ctx;
+    ngx_http_request_t  *r;
+
+    r = (ngx_http_request_t *) obj;
+
+    ctx = ngx_http_get_module_ctx(r, ngx_http_js_module);
+
+    njs_vm_retval_set(ctx->vm, &ctx->args[1]);
+
+    return NJS_OK;
+}
+
+
 static njs_host_event_t
 ngx_http_js_set_timer(njs_external_ptr_t external, uint64_t delay,
     njs_vm_event_t vm_event)


More information about the nginx-devel mailing list