Welcome! Log In Create A New Profile

Advanced

[njs] HTTP: avoid creating empty request_body buffer in r.subrequest().

Dmitry Volyntsev
February 26, 2019 08:34AM
details: https://hg.nginx.org/njs/rev/40b6f1030873
branches:
changeset: 801:40b6f1030873
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Tue Feb 26 16:16:08 2019 +0300
description:
HTTP: avoid creating empty request_body buffer in r.subrequest().

This fixes #101 issue on Github.

diffstat:

nginx/ngx_http_js_module.c | 34 ++++++++++++++++++----------------
1 files changed, 18 insertions(+), 16 deletions(-)

diffs (46 lines):

diff -r d49837819721 -r 40b6f1030873 nginx/ngx_http_js_module.c
--- a/nginx/ngx_http_js_module.c Mon Feb 25 19:00:56 2019 +0300
+++ b/nginx/ngx_http_js_module.c Tue Feb 26 16:16:08 2019 +0300
@@ -1869,24 +1869,26 @@ ngx_http_js_ext_subrequest(njs_vm_t *vm,
goto memory_error;
}

- rb->bufs = ngx_alloc_chain_link(r->pool);
- if (rb->bufs == NULL) {
- goto memory_error;
+ if (body_arg.length != 0) {
+ rb->bufs = ngx_alloc_chain_link(r->pool);
+ if (rb->bufs == NULL) {
+ goto memory_error;
+ }
+
+ rb->bufs->next = NULL;
+
+ rb->bufs->buf = ngx_calloc_buf(r->pool);
+ if (rb->bufs->buf == NULL) {
+ goto memory_error;
+ }
+
+ rb->bufs->buf->memory = 1;
+ rb->bufs->buf->last_buf = 1;
+
+ rb->bufs->buf->pos = body_arg.start;
+ rb->bufs->buf->last = body_arg.start + body_arg.length;
}

- rb->bufs->next = NULL;
-
- rb->bufs->buf = ngx_calloc_buf(r->pool);
- if (rb->bufs->buf == NULL) {
- goto memory_error;
- }
-
- rb->bufs->buf->memory = 1;
- rb->bufs->buf->last_buf = 1;
-
- rb->bufs->buf->pos = body_arg.start;
- rb->bufs->buf->last = body_arg.start + body_arg.length;
-
sr->request_body = rb;
sr->headers_in.content_length_n = body_arg.length;
sr->headers_in.chunked = 0;
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] HTTP: avoid creating empty request_body buffer in r.subrequest().

Dmitry Volyntsev 470 February 26, 2019 08:34AM



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

Online Users

Guests: 261
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