Welcome! Log In Create A New Profile

Advanced

[njs] Setting status code to 500 by default in js_content handler.

Dmitry Volyntsev
May 30, 2018 08:10AM
details: http://hg.nginx.org/njs/rev/1ac5805c9d19
branches:
changeset: 526:1ac5805c9d19
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Wed May 30 15:07:04 2018 +0300
description:
Setting status code to 500 by default in js_content handler.

This helps to debug incorrectly written content handlers.

diffstat:

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

diffs (36 lines):

diff -r b65fa3d62b74 -r 1ac5805c9d19 nginx/ngx_http_js_module.c
--- a/nginx/ngx_http_js_module.c Mon May 28 17:05:17 2018 +0300
+++ b/nginx/ngx_http_js_module.c Wed May 30 15:07:04 2018 +0300
@@ -671,6 +671,13 @@ ngx_http_js_content_event_handler(ngx_ht
return;
}

+ /*
+ * status is expected to be overriden by finish() or return() methods,
+ * otherwise the content handler is considered invalid.
+ */
+
+ ctx->status = NGX_HTTP_INTERNAL_SERVER_ERROR;
+
if (njs_vm_call(ctx->vm, func, njs_value_arg(ctx->args), 2) != NJS_OK) {
njs_vm_retval_to_ext_string(ctx->vm, &exception);

@@ -1269,6 +1276,7 @@ static njs_ret_t
ngx_http_js_ext_finish(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs,
njs_index_t unused)
{
+ ngx_http_js_ctx_t *ctx;
ngx_http_request_t *r;

r = njs_value_data(njs_argument(args, 0));
@@ -1277,6 +1285,10 @@ ngx_http_js_ext_finish(njs_vm_t *vm, njs
return NJS_ERROR;
}

+ ctx = ngx_http_get_module_ctx(r, ngx_http_js_module);
+
+ ctx->status = NGX_OK;
+
return NJS_OK;
}

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Setting status code to 500 by default in js_content handler.

Dmitry Volyntsev 475 May 30, 2018 08:10AM



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

Online Users

Guests: 295
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready