@@ -131,7 +131,7 @@ static ngx_int_t ngx_http_c_func_proceed_init_calls(ngx_cycle_t* cycle, ngx_htt
131131static u_char * ngx_http_c_func_strdup_with_p (ngx_pool_t * pool , const char * src , size_t len );
132132
133133static ngx_int_t ngx_http_c_func_get_resp_var (ngx_http_request_t * r , ngx_http_variable_value_t * v , uintptr_t data );
134- static void ngx_http_c_func_set_resp_var_with_r (ngx_http_request_t * r , ngx_http_c_func_ctx_t * ctx , const char * resp_content );
134+ static void ngx_http_c_func_set_resp_var_with_r (ngx_http_request_t * r , ngx_http_c_func_ctx_t * ctx , const char * resp_content , size_t resp_len );
135135static void ngx_http_c_func_output_filter (ngx_http_request_t * r );
136136
137137#if (NGX_THREADS )
@@ -182,7 +182,7 @@ void* ngx_http_c_func_cache_get(void *shared_mem, const char* key);
182182void * ngx_http_c_func_cache_put (void * shared_mem , const char * key , void * value );
183183void * ngx_http_c_func_cache_new (void * shared_mem , const char * key , size_t size );
184184void * ngx_http_c_func_cache_remove (void * shared_mem , const char * key );
185- void ngx_http_c_func_set_resp_var (ngx_http_c_func_ctx_t * ctx , const char * resp_content );
185+ void ngx_http_c_func_set_resp_var (ngx_http_c_func_ctx_t * ctx , const char * resp_content , size_t resp_len );
186186void ngx_http_c_func_write_resp (ngx_http_c_func_ctx_t * ctx , uintptr_t status_code , const char * status_line , const char * content_type , const char * resp_content , size_t resp_len );
187187void ngx_http_c_func_write_resp_l (ngx_http_c_func_ctx_t * ctx , uintptr_t status_code , const char * status_line ,
188188 size_t status_line_len , const char * content_type , size_t content_type_len ,
@@ -559,7 +559,7 @@ ngx_http_c_func_pre_configuration(ngx_conf_t *cf) {
559559 return NGX_ERROR ;
560560#endif
561561
562- #ifndef ngx_http_c_func_module_version_11
562+ #ifndef ngx_http_c_func_module_version_12
563563 ngx_conf_log_error (NGX_LOG_EMERG , cf , 0 , "%s" , "the latest ngx_http_c_func_module.h not found in the c header path, \
564564 please copy latest ngx_http_c_func_module.h to your /usr/include or /usr/local/include or relavent header search path \
565565 with read and write permission." );
@@ -1486,15 +1486,16 @@ ngx_http_c_func_get_resp_var(ngx_http_request_t *r,
14861486void
14871487ngx_http_c_func_set_resp_var (
14881488 ngx_http_c_func_ctx_t * ctx ,
1489- const char * resp_content
1489+ const char * resp_content ,
1490+ size_t resp_len
14901491) {
14911492 ngx_http_c_func_internal_ctx_t * internal_ctx ;
14921493 ngx_http_request_t * r = (ngx_http_request_t * )ctx -> __r__ ;
14931494 internal_ctx = ngx_http_get_module_ctx (r , ngx_http_c_func_module );
14941495
14951496 if (internal_ctx != NULL ) {
1496- internal_ctx -> resp_len = ngx_strlen ( resp_content ) ;
1497- internal_ctx -> resp = ngx_http_c_func_strdup_with_p (r -> pool , resp_content , internal_ctx -> resp_len );
1497+ internal_ctx -> resp_len = resp_len ;
1498+ internal_ctx -> resp = ngx_http_c_func_strdup_with_p (r -> pool , resp_content , resp_len );
14981499
14991500 /** Decline means continue to next handler for this phase **/
15001501 internal_ctx -> rc = NGX_DECLINED ;
@@ -1508,14 +1509,15 @@ static void
15081509ngx_http_c_func_set_resp_var_with_r (
15091510 ngx_http_request_t * r ,
15101511 ngx_http_c_func_ctx_t * ctx ,
1511- const char * resp_content
1512+ const char * resp_content ,
1513+ size_t resp_len
15121514) {
15131515 ngx_http_c_func_internal_ctx_t * internal_ctx ;
15141516 internal_ctx = ngx_http_get_module_ctx (r , ngx_http_c_func_module );
15151517
15161518 if (internal_ctx != NULL ) {
1517- internal_ctx -> resp_len = ngx_strlen ( resp_content ) ;
1518- internal_ctx -> resp = ngx_http_c_func_strdup_with_p (r -> pool , resp_content , internal_ctx -> resp_len );
1519+ internal_ctx -> resp_len = resp_len ;
1520+ internal_ctx -> resp = ngx_http_c_func_strdup_with_p (r -> pool , resp_content , resp_len );
15191521
15201522 /** Decline means continue to next handler for this phase **/
15211523 internal_ctx -> rc = NGX_DECLINED ;
@@ -1545,9 +1547,8 @@ ngx_http_c_func_write_resp_l(
15451547 if ( ((ngx_http_c_func_loc_conf_t * ) ngx_http_get_module_loc_conf (r , ngx_http_c_func_module ) )-> _is_call_to_var ) {
15461548 ngx_log_error (NGX_LOG_WARN ,
15471549 r -> connection -> log ,
1548- 0 , "Recommended to call ngx_http_c_func_set_resp_var. \
1549- ngx_http_c_func_write_resp only applicable when no variable specified" );
1550- ngx_http_c_func_set_resp_var_with_r (r , appctx , resp_content );
1550+ 0 , "Recommended to call ngx_http_c_func_set_resp_var. ngx_http_c_func_write_resp only applicable when no variable specified" );
1551+ ngx_http_c_func_set_resp_var_with_r (r , appctx , resp_content , resp_content_len );
15511552 return ;
15521553 }
15531554
0 commit comments