@@ -1133,6 +1133,7 @@ static JSClassDef ngx_http_qjs_headers_out_class = {
1133
1133
qjs_module_t * njs_http_qjs_addon_modules [] = {
1134
1134
& ngx_qjs_ngx_module ,
1135
1135
& ngx_qjs_ngx_shared_dict_module ,
1136
+ & ngx_qjs_ngx_fetch_module ,
1136
1137
/*
1137
1138
* Shared addons should be in the same order and the same positions
1138
1139
* in all nginx modules.
@@ -5133,7 +5134,7 @@ ngx_http_qjs_ext_internal_redirect(JSContext *cx, JSValueConst this_val,
5133
5134
"internalRedirect cannot be called while filtering" );
5134
5135
}
5135
5136
5136
- if (ngx_qjs_string (ctx -> engine , argv [0 ], & ctx -> redirect_uri ) != NGX_OK ) {
5137
+ if (ngx_qjs_string (cx , argv [0 ], & ctx -> redirect_uri ) != NGX_OK ) {
5137
5138
return JS_EXCEPTION ;
5138
5139
}
5139
5140
@@ -5412,7 +5413,7 @@ ngx_http_qjs_ext_return(JSContext *cx, JSValueConst this_val,
5412
5413
ctx = ngx_http_get_module_ctx (r , ngx_http_js_module );
5413
5414
5414
5415
if (status < NGX_HTTP_BAD_REQUEST || !JS_IsNullOrUndefined (argv [1 ])) {
5415
- if (ngx_qjs_string (ctx -> engine , argv [1 ], & body ) != NGX_OK ) {
5416
+ if (ngx_qjs_string (cx , argv [1 ], & body ) != NGX_OK ) {
5416
5417
return JS_ThrowOutOfMemory (cx );
5417
5418
}
5418
5419
@@ -5515,7 +5516,7 @@ ngx_http_qjs_ext_send(JSContext *cx, JSValueConst this_val,
5515
5516
ll = & out ;
5516
5517
5517
5518
for (n = 0 ; n < (ngx_uint_t ) argc ; n ++ ) {
5518
- if (ngx_qjs_string (ctx -> engine , argv [n ], & s ) != NGX_OK ) {
5519
+ if (ngx_qjs_string (cx , argv [n ], & s ) != NGX_OK ) {
5519
5520
return JS_ThrowTypeError (cx , "failed to convert arg" );
5520
5521
}
5521
5522
@@ -5578,7 +5579,7 @@ ngx_http_qjs_ext_send_buffer(JSContext *cx, JSValueConst this_val,
5578
5579
return JS_ThrowTypeError (cx , "cannot send buffer while not filtering" );
5579
5580
}
5580
5581
5581
- if (ngx_qjs_string (ctx -> engine , argv [0 ], & buffer ) != NGX_OK ) {
5582
+ if (ngx_qjs_string (cx , argv [0 ], & buffer ) != NGX_OK ) {
5582
5583
return JS_ThrowTypeError (cx , "failed get buffer arg" );
5583
5584
}
5584
5585
@@ -5735,7 +5736,7 @@ ngx_http_qjs_subrequest_done(ngx_http_request_t *r, void *data, ngx_int_t rc)
5735
5736
reply = JS_DupValue (cx , ngx_qjs_arg (sctx -> args [0 ]));
5736
5737
}
5737
5738
5738
- rc = ngx_qjs_call (( ngx_js_ctx_t * ) ctx , event -> function , & reply , 1 );
5739
+ rc = ngx_qjs_call (cx , event -> function , & reply , 1 );
5739
5740
5740
5741
JS_FreeValue (cx , reply );
5741
5742
ngx_js_del_event (ctx , event );
@@ -5786,7 +5787,7 @@ ngx_http_qjs_ext_subrequest(JSContext *cx, JSValueConst this_val,
5786
5787
"the primary request" );
5787
5788
}
5788
5789
5789
- if (ngx_qjs_string (ctx -> engine , argv [0 ], & uri ) != NGX_OK ) {
5790
+ if (ngx_qjs_string (cx , argv [0 ], & uri ) != NGX_OK ) {
5790
5791
return JS_ThrowTypeError (cx , "failed to convert uri arg" );
5791
5792
}
5792
5793
@@ -5812,7 +5813,7 @@ ngx_http_qjs_ext_subrequest(JSContext *cx, JSValueConst this_val,
5812
5813
arg = argv [1 ];
5813
5814
5814
5815
if (JS_IsString (arg )) {
5815
- if (ngx_qjs_string (ctx -> engine , arg , & args ) != NGX_OK ) {
5816
+ if (ngx_qjs_string (cx , arg , & args ) != NGX_OK ) {
5816
5817
return JS_ThrowTypeError (cx , "failed to convert args" );
5817
5818
}
5818
5819
@@ -5833,7 +5834,7 @@ ngx_http_qjs_ext_subrequest(JSContext *cx, JSValueConst this_val,
5833
5834
}
5834
5835
5835
5836
if (!JS_IsUndefined (value )) {
5836
- rc = ngx_qjs_string (ctx -> engine , value , & args );
5837
+ rc = ngx_qjs_string (cx , value , & args );
5837
5838
JS_FreeValue (cx , value );
5838
5839
5839
5840
if (rc != NGX_OK ) {
@@ -5857,7 +5858,7 @@ ngx_http_qjs_ext_subrequest(JSContext *cx, JSValueConst this_val,
5857
5858
}
5858
5859
5859
5860
if (!JS_IsUndefined (value )) {
5860
- rc = ngx_qjs_string (ctx -> engine , value , & method_name );
5861
+ rc = ngx_qjs_string (cx , value , & method_name );
5861
5862
JS_FreeValue (cx , value );
5862
5863
5863
5864
if (rc != NGX_OK ) {
@@ -5884,7 +5885,7 @@ ngx_http_qjs_ext_subrequest(JSContext *cx, JSValueConst this_val,
5884
5885
}
5885
5886
5886
5887
if (!JS_IsUndefined (value )) {
5887
- rc = ngx_qjs_string (ctx -> engine , value , & body_arg );
5888
+ rc = ngx_qjs_string (cx , value , & body_arg );
5888
5889
JS_FreeValue (cx , value );
5889
5890
5890
5891
if (rc != NGX_OK ) {
@@ -6233,7 +6234,6 @@ ngx_http_qjs_variables_set_property(JSContext *cx, JSValueConst obj,
6233
6234
u_char * lowcase_key ;
6234
6235
ngx_str_t name , s ;
6235
6236
ngx_uint_t key ;
6236
- ngx_http_js_ctx_t * ctx ;
6237
6237
ngx_http_request_t * r ;
6238
6238
ngx_http_variable_t * v ;
6239
6239
ngx_http_variable_value_t * vv ;
@@ -6279,9 +6279,7 @@ ngx_http_qjs_variables_set_property(JSContext *cx, JSValueConst obj,
6279
6279
return -1 ;
6280
6280
}
6281
6281
6282
- ctx = ngx_http_get_module_ctx (r , ngx_http_js_module );
6283
-
6284
- if (ngx_qjs_string (ctx -> engine , value , & s ) != NGX_OK ) {
6282
+ if (ngx_qjs_string (cx , value , & s ) != NGX_OK ) {
6285
6283
return -1 ;
6286
6284
}
6287
6285
@@ -6514,15 +6512,10 @@ ngx_http_qjs_header_generic(JSContext *cx, ngx_http_request_t *r,
6514
6512
pdesc -> setter = JS_UNDEFINED ;
6515
6513
pdesc -> value = qjs_string_create_chb (cx , & chain );
6516
6514
if (JS_IsException (pdesc -> value )) {
6517
- ret = -1 ;
6518
- goto done ;
6515
+ return -1 ;
6519
6516
}
6520
6517
}
6521
6518
6522
- done :
6523
-
6524
- njs_chb_destroy (& chain );
6525
-
6526
6519
return ret ;
6527
6520
}
6528
6521
@@ -6692,15 +6685,14 @@ ngx_http_qjs_headers_out_handler(JSContext *cx, ngx_http_request_t *r,
6692
6685
ngx_str_t * name , JSPropertyDescriptor * pdesc , JSValue * value ,
6693
6686
unsigned flags )
6694
6687
{
6695
- u_char * p ;
6696
- int64_t length ;
6697
- uint32_t i ;
6698
- ngx_int_t rc ;
6699
- ngx_str_t s ;
6700
- JSValue v ;
6701
- ngx_list_part_t * part ;
6702
- ngx_table_elt_t * header , * h , * * ph ;
6703
- ngx_http_js_ctx_t * ctx ;
6688
+ u_char * p ;
6689
+ int64_t length ;
6690
+ uint32_t i ;
6691
+ ngx_int_t rc ;
6692
+ ngx_str_t s ;
6693
+ JSValue v ;
6694
+ ngx_list_part_t * part ;
6695
+ ngx_table_elt_t * header , * h , * * ph ;
6704
6696
6705
6697
if (flags & NJS_HEADER_GET ) {
6706
6698
return ngx_http_qjs_header_generic (cx , r , & r -> headers_out .headers , NULL ,
@@ -6758,7 +6750,6 @@ ngx_http_qjs_headers_out_handler(JSContext *cx, ngx_http_request_t *r,
6758
6750
}
6759
6751
6760
6752
ph = & header ;
6761
- ctx = ngx_http_get_module_ctx (r , ngx_http_js_module );
6762
6753
6763
6754
for (i = 0 ; i < (uint32_t ) length ; i ++ ) {
6764
6755
if (JS_IsArray (cx , * value )) {
@@ -6768,7 +6759,7 @@ ngx_http_qjs_headers_out_handler(JSContext *cx, ngx_http_request_t *r,
6768
6759
}
6769
6760
}
6770
6761
6771
- rc = ngx_qjs_string (ctx -> engine , v , & s );
6762
+ rc = ngx_qjs_string (cx , v , & s );
6772
6763
6773
6764
if (JS_IsArray (cx , * value )) {
6774
6765
JS_FreeValue (cx , v );
@@ -6828,15 +6819,14 @@ ngx_http_qjs_headers_out_special_handler(JSContext *cx, ngx_http_request_t *r,
6828
6819
ngx_str_t * name , JSPropertyDescriptor * pdesc , JSValue * value ,
6829
6820
unsigned flags , ngx_table_elt_t * * hh )
6830
6821
{
6831
- u_char * p ;
6832
- uint32_t length ;
6833
- JSValue len , setval ;
6834
- ngx_str_t s ;
6835
- ngx_uint_t i , rc ;
6836
- ngx_list_t * headers ;
6837
- ngx_list_part_t * part ;
6838
- ngx_table_elt_t * header , * h ;
6839
- ngx_http_js_ctx_t * ctx ;
6822
+ u_char * p ;
6823
+ uint32_t length ;
6824
+ JSValue len , setval ;
6825
+ ngx_str_t s ;
6826
+ ngx_uint_t i , rc ;
6827
+ ngx_list_t * headers ;
6828
+ ngx_list_part_t * part ;
6829
+ ngx_table_elt_t * header , * h ;
6840
6830
6841
6831
if (flags & NJS_HEADER_GET ) {
6842
6832
return ngx_http_qjs_headers_out_handler (cx , r , name , pdesc , NULL ,
@@ -6870,9 +6860,7 @@ ngx_http_qjs_headers_out_special_handler(JSContext *cx, ngx_http_request_t *r,
6870
6860
setval = JS_UNDEFINED ;
6871
6861
}
6872
6862
6873
- ctx = ngx_http_get_module_ctx (r , ngx_http_js_module );
6874
-
6875
- rc = ngx_qjs_string (ctx -> engine , setval , & s );
6863
+ rc = ngx_qjs_string (cx , setval , & s );
6876
6864
6877
6865
if (value != NULL && JS_IsArray (cx , * value )) {
6878
6866
JS_FreeValue (cx , setval );
@@ -7050,11 +7038,10 @@ ngx_http_qjs_headers_out_content_type(JSContext *cx, ngx_http_request_t *r,
7050
7038
ngx_str_t * name , JSPropertyDescriptor * pdesc , JSValue * value ,
7051
7039
unsigned flags )
7052
7040
{
7053
- uint32_t length ;
7041
+ uint32_t length ;
7054
7042
JSValue len , setval ;
7055
7043
ngx_int_t rc ;
7056
7044
ngx_str_t * hdr , s ;
7057
- ngx_http_js_ctx_t * ctx ;
7058
7045
7059
7046
if (flags & NJS_HEADER_GET ) {
7060
7047
hdr = & r -> headers_out .content_type ;
@@ -7108,9 +7095,7 @@ ngx_http_qjs_headers_out_content_type(JSContext *cx, ngx_http_request_t *r,
7108
7095
setval = * value ;
7109
7096
}
7110
7097
7111
- ctx = ngx_http_get_module_ctx (r , ngx_http_js_module );
7112
-
7113
- rc = ngx_qjs_string (ctx -> engine , setval , & s );
7098
+ rc = ngx_qjs_string (cx , setval , & s );
7114
7099
7115
7100
if (JS_IsArray (cx , * value )) {
7116
7101
JS_FreeValue (cx , setval );
0 commit comments