Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

buffer only subrequests issued by JS module (closes #41)

  • Loading branch information...
commit 7cc1469235c3ee1912114885617ddad4a2344b7c 1 parent 41fdc35
@kung-fu-tzu authored
Showing with 12 additions and 1 deletion.
  1. +12 −1 src/classes/Request.c
View
13 src/classes/Request.c
@@ -936,6 +936,7 @@ method_subrequest(JSContext *cx, JSObject *self, uintN argc, jsval *argv, jsval
ngx_http_post_subrequest_t *psr;
ngx_str_t uri, args;
ngx_uint_t flags;
+ ngx_http_js_ctx_t *sr_ctx;
JSString *str;
JSObject *subrequest;
@@ -989,7 +990,6 @@ method_subrequest(JSContext *cx, JSObject *self, uintN argc, jsval *argv, jsval
JS_ReportOutOfMemory(cx);
return JS_FALSE;
}
- // sr->filter_need_in_memory = 1;
subrequest = ngx_http_js__nginx_request__wrap(cx, sr);
if (subrequest == NULL)
@@ -998,6 +998,17 @@ method_subrequest(JSContext *cx, JSObject *self, uintN argc, jsval *argv, jsval
return JS_FALSE;
}
+ // context must be successfully created in ngx_http_js__nginx_request__wrap()
+ sr_ctx = ngx_http_get_module_ctx(sr, ngx_http_js_module);
+ ngx_assert(sr_ctx);
+ // ask body filter to buffer all the data
+ sr_ctx->filter_enabled = 1;
+ sr_ctx->chain_first = NULL;
+ sr_ctx->chain_last = NULL;
+
+ sr->filter_need_in_memory = 1;
+
+
if (!JS_SetReservedSlot(cx, subrequest, NGX_JS_REQUEST_SLOT__SUBREQUEST_CALLBACK, argv[1]))
{
JS_ReportError(cx, "can't set slot NGX_JS_REQUEST_SLOT__SUBREQUEST_CALLBACK(%d)", NGX_JS_REQUEST_SLOT__SUBREQUEST_CALLBACK);
Please sign in to comment.
Something went wrong with that request. Please try again.