aboutsummaryrefslogtreecommitdiff
path: root/nginx/ngx_http_js_module.c
diff options
context:
space:
mode:
authorDmitry Volyntsev <xeioex@nginx.com>2019-02-26 16:16:08 +0300
committerDmitry Volyntsev <xeioex@nginx.com>2019-02-26 16:16:08 +0300
commit7ea8469add10ba91db85a2db27ece20b151216f4 (patch)
treeaa35b7f813cb7c5b661265f53d28d5055871c1d6 /nginx/ngx_http_js_module.c
parenta118a994e69b16062d3186b2802917e85fc3c98d (diff)
downloadnjs-7ea8469add10ba91db85a2db27ece20b151216f4.tar.gz
njs-7ea8469add10ba91db85a2db27ece20b151216f4.zip
HTTP: avoid creating empty request_body buffer in r.subrequest().
This fixes #101 issue on Github.
Diffstat (limited to 'nginx/ngx_http_js_module.c')
-rw-r--r--nginx/ngx_http_js_module.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/nginx/ngx_http_js_module.c b/nginx/ngx_http_js_module.c
index b0ac8471..0705d5a8 100644
--- a/nginx/ngx_http_js_module.c
+++ b/nginx/ngx_http_js_module.c
@@ -1869,23 +1869,25 @@ ngx_http_js_ext_subrequest(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs,
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->next = NULL;
- rb->bufs->buf = ngx_calloc_buf(r->pool);
- if (rb->bufs->buf == NULL) {
- goto memory_error;
- }
+ 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->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->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;