@@ -118,7 +118,7 @@ static ngx_int_t ngx_http_c_func_module_init(ngx_cycle_t *cycle);
118
118
static void ngx_http_c_func_master_exit (ngx_cycle_t * cycle );
119
119
static void ngx_http_c_func_client_body_handler (ngx_http_request_t * r );
120
120
static ngx_int_t ngx_http_c_func_proceed_init_calls (ngx_cycle_t * cycle , ngx_http_c_func_srv_conf_t * scf , ngx_http_c_func_main_conf_t * mcf );
121
- static u_char * ngx_http_c_func_strdup (ngx_pool_t * pool , const char * src , size_t len );
121
+ static u_char * ngx_http_c_func_strdup_with_p (ngx_pool_t * pool , const char * src , size_t len );
122
122
123
123
static ngx_int_t ngx_http_c_func_get_resp_var (ngx_http_request_t * r , ngx_http_variable_value_t * v , uintptr_t data );
124
124
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 );
@@ -149,6 +149,7 @@ void ngx_http_c_func_log_debug(ngx_http_c_func_ctx_t *ctx, const char* msg);
149
149
void ngx_http_c_func_log_info (ngx_http_c_func_ctx_t * ctx , const char * msg );
150
150
void ngx_http_c_func_log_warn (ngx_http_c_func_ctx_t * ctx , const char * msg );
151
151
void ngx_http_c_func_log_err (ngx_http_c_func_ctx_t * ctx , const char * msg );
152
+ char * ngx_http_c_func_strdup (ngx_http_c_func_ctx_t * ctx , const char * src );
152
153
u_char * ngx_http_c_func_get_header (ngx_http_c_func_ctx_t * ctx , const char * key );
153
154
void * ngx_http_c_func_get_query_param (ngx_http_c_func_ctx_t * ctx , const char * key );
154
155
void * ngx_http_c_func_palloc (ngx_http_c_func_ctx_t * ctx , size_t size );
@@ -532,7 +533,7 @@ ngx_http_c_func_post_configuration(ngx_conf_t *cf) {
532
533
static ngx_int_t
533
534
ngx_http_c_func_pre_configuration (ngx_conf_t * cf ) {
534
535
535
- #ifndef ngx_http_c_func_module_version_8
536
+ #ifndef ngx_http_c_func_module_version_9
536
537
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, \
537
538
please copy latest ngx_http_c_func_module.h to your /usr/include or /usr/local/include or relavent header search path \
538
539
with read and write permission." );
@@ -1103,8 +1104,19 @@ ngx_http_c_func_log_err(ngx_http_c_func_ctx_t *ctx, const char* msg) {
1103
1104
ngx_log_error (NGX_LOG_ERR , (ngx_log_t * )ctx -> __log__ , 0 , "%s" , msg );
1104
1105
}
1105
1106
1107
+ char *
1108
+ ngx_http_c_func_strdup (ngx_http_c_func_ctx_t * ctx , const char * src ) {
1109
+ char * dst ;
1110
+ if (src == NULL ) return NULL ;
1111
+ size_t len = ngx_strlen (src );
1112
+ dst = (char * ) ngx_palloc ((ngx_pool_t * )ctx -> __pl__ , (len + 1 ) * sizeof (char ));
1113
+ ngx_memcpy (dst , src , len );
1114
+ dst [len ] = '\0' ;
1115
+ return dst ;
1116
+ }
1117
+
1106
1118
static u_char *
1107
- ngx_http_c_func_strdup (ngx_pool_t * pool , const char * src , size_t len ) {
1119
+ ngx_http_c_func_strdup_with_p (ngx_pool_t * pool , const char * src , size_t len ) {
1108
1120
u_char * dst ;
1109
1121
dst = ngx_pcalloc (pool , len + 1 );
1110
1122
if (dst == NULL ) {
@@ -1404,11 +1416,11 @@ ngx_http_c_func_write_resp(
1404
1416
/* Set the Content-Type header. */
1405
1417
if (content_type ) {
1406
1418
r -> headers_out .content_type .len = ngx_strlen (content_type );
1407
- r -> headers_out .content_type .data = ngx_http_c_func_strdup (r -> pool , content_type , r -> headers_out .content_type .len );
1419
+ r -> headers_out .content_type .data = ngx_http_c_func_strdup_with_p (r -> pool , content_type , r -> headers_out .content_type .len );
1408
1420
} else {
1409
1421
static const char * plaintext_content_type = ngx_http_c_func_content_type_plaintext ;
1410
1422
r -> headers_out .content_type .len = ngx_strlen (plaintext_content_type );
1411
- r -> headers_out .content_type .data = ngx_http_c_func_strdup (r -> pool , plaintext_content_type , r -> headers_out .content_type .len );
1423
+ r -> headers_out .content_type .data = ngx_http_c_func_strdup_with_p (r -> pool , plaintext_content_type , r -> headers_out .content_type .len );
1412
1424
}
1413
1425
1414
1426
ngx_buf_t * b ;
@@ -1433,7 +1445,7 @@ ngx_http_c_func_write_resp(
1433
1445
1434
1446
if (status_line ) {
1435
1447
r -> headers_out .status_line .len = ngx_strlen (status_line );
1436
- r -> headers_out .status_line .data = ngx_http_c_func_strdup (r -> pool , status_line , r -> headers_out .status_line .len );
1448
+ r -> headers_out .status_line .data = ngx_http_c_func_strdup_with_p (r -> pool , status_line , r -> headers_out .status_line .len );
1437
1449
}
1438
1450
1439
1451
/* Get the content length of the body. */
0 commit comments