static ngx_http_output_body_filter_pt ngx_http_next_body_filter;
+static njs_int_t ngx_http_js_request_proto_id;
+
+
static njs_external_t ngx_http_js_ext_request[] = {
{
}
rc = njs_vm_external_create(ctx->vm, njs_value_arg(&ctx->request),
- NGX_JS_PROTO_MAIN, r, 0);
+ ngx_http_js_request_proto_id, r, 0);
if (rc != NJS_OK) {
return NGX_ERROR;
}
}
ret = njs_vm_external_create(ctx->vm, njs_value_arg(&reply),
- NGX_JS_PROTO_MAIN, r, 0);
+ ngx_http_js_request_proto_id, r, 0);
if (ret != NJS_OK) {
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
"js subrequest reply creation failed");
ssize_t n;
ngx_fd_t fd;
ngx_str_t *m, file;
- njs_int_t rc, proto_id;
+ njs_int_t rc;
njs_str_t text, path;
ngx_uint_t i;
njs_value_t *value;
}
}
- proto_id = njs_vm_external_prototype(jmcf->vm, ngx_http_js_ext_request,
- njs_nitems(ngx_http_js_ext_request));
- if (proto_id < 0) {
+ ngx_http_js_request_proto_id = njs_vm_external_prototype(jmcf->vm,
+ ngx_http_js_ext_request,
+ njs_nitems(ngx_http_js_ext_request));
+ if (ngx_http_js_request_proto_id < 0) {
ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
"failed to add js request proto");
return NGX_CONF_ERROR;
#define NGX_JS_STRING 1
#define NGX_JS_BUFFER 2
-#define NGX_JS_PROTO_MAIN 0
-#define NGX_JS_PROTO_RESPONSE 1
-
typedef ngx_pool_t *(*ngx_external_pool_pt)(njs_vm_t *vm, njs_external_ptr_t e);
typedef void (*ngx_js_event_handler_pt)(njs_external_ptr_t e,
};
+static njs_int_t ngx_http_js_fetch_proto_id;
+
+
njs_int_t
ngx_js_ext_fetch(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
njs_index_t unused)
if (size == http->http_parse.content_length_n) {
ret = njs_vm_external_create(http->vm, njs_value_arg(&http->reply),
- NGX_JS_PROTO_RESPONSE, http, 0);
+ ngx_http_js_fetch_proto_id, http, 0);
if (ret != NJS_OK) {
ngx_js_http_error(http, 0, "fetch object creation failed");
return NGX_ERROR;
ngx_int_t
ngx_js_fetch_init(njs_vm_t *vm, ngx_log_t *log)
{
- njs_int_t proto_id;
-
- proto_id = njs_vm_external_prototype(vm, ngx_js_ext_http_response,
- njs_nitems(ngx_js_ext_http_response));
- if (proto_id != NGX_JS_PROTO_RESPONSE) {
+ ngx_http_js_fetch_proto_id = njs_vm_external_prototype(vm,
+ ngx_js_ext_http_response,
+ njs_nitems(ngx_js_ext_http_response));
+ if (ngx_http_js_fetch_proto_id < 0) {
ngx_log_error(NGX_LOG_EMERG, log, 0,
"failed to add js http.response proto");
return NGX_ERROR;
static ngx_stream_filter_pt ngx_stream_next_filter;
+static njs_int_t ngx_stream_js_session_proto_id;
+
+
static ngx_int_t
ngx_stream_js_access_handler(ngx_stream_session_t *s)
{
}
rc = njs_vm_external_create(ctx->vm, njs_value_arg(&ctx->args[0]),
- NGX_JS_PROTO_MAIN, s, 0);
+ ngx_stream_js_session_proto_id, s, 0);
if (rc != NJS_OK) {
return NGX_ERROR;
}
ssize_t n;
ngx_fd_t fd;
ngx_str_t *m, file;
- njs_int_t rc, proto_id;
+ njs_int_t rc;
njs_str_t text, path;
ngx_uint_t i;
njs_value_t *value;
}
}
- proto_id = njs_vm_external_prototype(jmcf->vm, ngx_stream_js_ext_session,
+ ngx_stream_js_session_proto_id = njs_vm_external_prototype(jmcf->vm,
+ ngx_stream_js_ext_session,
njs_nitems(ngx_stream_js_ext_session));
- if (proto_id < 0) {
+ if (ngx_stream_js_session_proto_id < 0) {
ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
"failed to add js request proto");
return NGX_CONF_ERROR;