14
14
typedef struct {
15
15
ngx_buf_t * request_buffer ;
16
16
ngx_http_status_t status ;
17
- } child_request_base_context_t ; // fields common to dump requests and child requests
17
+ } ngx_child_request_base_context_t ; // fields common to dump requests and child requests
18
18
19
19
typedef struct {
20
- child_request_base_context_t base ; // must be first
20
+ ngx_child_request_base_context_t base ; // must be first
21
21
22
- child_request_callback_t callback ;
22
+ ngx_child_request_callback_t callback ;
23
23
void * callback_context ;
24
24
25
25
u_char * headers_buffer ;
@@ -31,7 +31,7 @@ typedef struct {
31
31
off_t response_buffer_size ;
32
32
33
33
ngx_http_upstream_conf_t * upstream_conf ;
34
- } child_request_context_t ;
34
+ } ngx_child_request_context_t ;
35
35
36
36
// globals
37
37
static ngx_str_t child_http_hide_headers [] = {
@@ -47,7 +47,7 @@ static ngx_int_t
47
47
ngx_http_vod_create_request (ngx_http_request_t * r )
48
48
{
49
49
ngx_chain_t * cl ;
50
- child_request_base_context_t * ctx ;
50
+ ngx_child_request_base_context_t * ctx ;
51
51
52
52
ngx_log_debug0 (NGX_LOG_DEBUG_HTTP , r -> connection -> log , 0 , "ngx_http_vod_create_request: started" );
53
53
@@ -88,7 +88,7 @@ ngx_http_vod_reinit_request(ngx_http_request_t *r)
88
88
static ngx_int_t
89
89
ngx_http_vod_process_header (ngx_http_request_t * r )
90
90
{
91
- child_request_context_t * ctx ;
91
+ ngx_child_request_context_t * ctx ;
92
92
ngx_http_upstream_t * u ;
93
93
ngx_table_elt_t * h ;
94
94
ngx_int_t rc ;
@@ -173,7 +173,7 @@ ngx_http_vod_process_header(ngx_http_request_t *r)
173
173
174
174
if (rc == NGX_HTTP_PARSE_HEADER_DONE ) // finished reading all headers
175
175
{
176
- // in case of dump_request , no need to do anything
176
+ // in case of ngx_dump_request , no need to do anything
177
177
if (is_dump_request (r ))
178
178
{
179
179
return NGX_OK ;
@@ -235,7 +235,7 @@ ngx_http_vod_process_header(ngx_http_request_t *r)
235
235
static ngx_int_t
236
236
ngx_http_vod_process_status_line (ngx_http_request_t * r )
237
237
{
238
- child_request_base_context_t * ctx ;
238
+ ngx_child_request_base_context_t * ctx ;
239
239
ngx_http_upstream_t * u ;
240
240
size_t len ;
241
241
ngx_int_t rc ;
@@ -299,7 +299,7 @@ ngx_http_vod_abort_request(ngx_http_request_t *r)
299
299
static ngx_int_t
300
300
ngx_http_vod_filter_init (void * data )
301
301
{
302
- child_request_context_t * ctx ;
302
+ ngx_child_request_context_t * ctx ;
303
303
ngx_http_request_t * r = data ;
304
304
ngx_http_upstream_t * u ;
305
305
@@ -337,7 +337,7 @@ ngx_http_vod_filter(void *data, ssize_t bytes)
337
337
}
338
338
339
339
static ngx_int_t
340
- create_upstream (
340
+ ngx_create_upstream (
341
341
ngx_http_request_t * r ,
342
342
ngx_http_upstream_conf_t * conf )
343
343
{
@@ -349,7 +349,7 @@ create_upstream(
349
349
if (rc != NGX_OK )
350
350
{
351
351
ngx_log_error (NGX_LOG_ERR , r -> connection -> log , 0 ,
352
- "create_upstream : failed to create upstream rc=%i" , rc );
352
+ "ngx_create_upstream : failed to create upstream rc=%i" , rc );
353
353
return NGX_ERROR ;
354
354
}
355
355
@@ -372,7 +372,7 @@ create_upstream(
372
372
}
373
373
374
374
static ngx_flag_t
375
- should_proxy_header (ngx_table_elt_t * header , child_request_params_t * params )
375
+ ngx_should_proxy_header (ngx_table_elt_t * header , ngx_child_request_params_t * params )
376
376
{
377
377
if (header -> key .len == sizeof ("host" ) - 1 &&
378
378
ngx_memcmp (header -> lowcase_key , "host" , sizeof ("host" ) - 1 ) == 0 )
@@ -398,10 +398,10 @@ should_proxy_header(ngx_table_elt_t* header, child_request_params_t* params)
398
398
}
399
399
400
400
static ngx_buf_t *
401
- init_request_buffer (
401
+ ngx_init_request_buffer (
402
402
ngx_http_request_t * r ,
403
403
ngx_buf_t * request_buffer ,
404
- child_request_params_t * params )
404
+ ngx_child_request_params_t * params )
405
405
{
406
406
ngx_http_core_srv_conf_t * cscf ;
407
407
ngx_list_part_t * part ;
@@ -453,7 +453,7 @@ init_request_buffer(
453
453
i = 0 ;
454
454
}
455
455
456
- if (!should_proxy_header (& header [i ], params ))
456
+ if (!ngx_should_proxy_header (& header [i ], params ))
457
457
{
458
458
continue ;
459
459
}
@@ -475,7 +475,7 @@ init_request_buffer(
475
475
if (b == NULL )
476
476
{
477
477
ngx_log_debug0 (NGX_LOG_DEBUG_HTTP , r -> connection -> log , 0 ,
478
- "init_request_buffer : ngx_create_temp_buf failed" );
478
+ "ngx_init_request_buffer : ngx_create_temp_buf failed" );
479
479
return NULL ;
480
480
}
481
481
p = b -> last ;
@@ -537,7 +537,7 @@ init_request_buffer(
537
537
i = 0 ;
538
538
}
539
539
540
- if (!should_proxy_header (& header [i ], params ))
540
+ if (!ngx_should_proxy_header (& header [i ], params ))
541
541
{
542
542
continue ;
543
543
}
@@ -560,39 +560,39 @@ init_request_buffer(
560
560
}
561
561
562
562
ngx_int_t
563
- dump_request (
563
+ ngx_dump_request (
564
564
ngx_http_request_t * r ,
565
565
ngx_http_upstream_conf_t * upstream_conf ,
566
- child_request_params_t * params )
566
+ ngx_child_request_params_t * params )
567
567
{
568
- child_request_base_context_t * ctx ;
568
+ ngx_child_request_base_context_t * ctx ;
569
569
ngx_int_t rc ;
570
570
571
- // replace the module context - after calling dump_request the caller is not allowed to use the context
571
+ // replace the module context - after calling ngx_dump_request the caller is not allowed to use the context
572
572
ctx = ngx_pcalloc (r -> pool , sizeof (* ctx ));
573
573
if (ctx == NULL )
574
574
{
575
575
ngx_log_debug0 (NGX_LOG_DEBUG_HTTP , r -> connection -> log , 0 ,
576
- "dump_request : ngx_pcalloc failed" );
576
+ "ngx_dump_request : ngx_pcalloc failed" );
577
577
return NGX_ERROR ;
578
578
}
579
579
ngx_http_set_ctx (r , ctx , ngx_http_vod_module );
580
580
581
581
// create an upstream
582
- rc = create_upstream (r , upstream_conf );
582
+ rc = ngx_create_upstream (r , upstream_conf );
583
583
if (rc != NGX_OK )
584
584
{
585
585
ngx_log_debug1 (NGX_LOG_DEBUG_HTTP , r -> connection -> log , 0 ,
586
- "dump_request: create_upstream failed %i" , rc );
586
+ "ngx_dump_request: ngx_create_upstream failed %i" , rc );
587
587
return rc ;
588
588
}
589
589
590
590
// build the request
591
- ctx -> request_buffer = init_request_buffer (r , NULL , params );
591
+ ctx -> request_buffer = ngx_init_request_buffer (r , NULL , params );
592
592
if (ctx -> request_buffer == NULL )
593
593
{
594
594
ngx_log_debug0 (NGX_LOG_DEBUG_HTTP , r -> connection -> log , 0 ,
595
- "dump_request: init_request_buffer failed" );
595
+ "ngx_dump_request: ngx_init_request_buffer failed" );
596
596
return NGX_ERROR ;
597
597
}
598
598
@@ -603,19 +603,19 @@ dump_request(
603
603
}
604
604
605
605
ngx_int_t
606
- child_request_internal_handler (ngx_http_request_t * r )
606
+ ngx_child_request_internal_handler (ngx_http_request_t * r )
607
607
{
608
- child_request_context_t * ctx ;
608
+ ngx_child_request_context_t * ctx ;
609
609
ngx_http_upstream_t * u ;
610
610
ngx_int_t rc ;
611
611
612
612
// create the upstream
613
613
ctx = ngx_http_get_module_ctx (r , ngx_http_vod_module );
614
- rc = create_upstream (r , ctx -> upstream_conf );
614
+ rc = ngx_create_upstream (r , ctx -> upstream_conf );
615
615
if (rc != NGX_OK )
616
616
{
617
617
ngx_log_debug1 (NGX_LOG_DEBUG_HTTP , r -> connection -> log , 0 ,
618
- "child_request_internal_handler: create_upstream failed %i" , rc );
618
+ "ngx_child_request_internal_handler: ngx_create_upstream failed %i" , rc );
619
619
return rc ;
620
620
}
621
621
@@ -632,7 +632,7 @@ child_request_internal_handler(ngx_http_request_t *r)
632
632
if (ngx_list_init (& u -> headers_in .headers , r -> pool , 8 , sizeof (ngx_table_elt_t )) != NGX_OK )
633
633
{
634
634
ngx_log_debug0 (NGX_LOG_DEBUG_HTTP , r -> connection -> log , 0 ,
635
- "child_request_internal_handler : ngx_list_init failed" );
635
+ "ngx_child_request_internal_handler : ngx_list_init failed" );
636
636
return NGX_ERROR ;
637
637
}
638
638
@@ -652,9 +652,9 @@ child_request_internal_handler(ngx_http_request_t *r)
652
652
}
653
653
654
654
static ngx_int_t
655
- child_request_finished_handler (ngx_http_request_t * r , void * data , ngx_int_t rc )
655
+ ngx_child_request_finished_handler (ngx_http_request_t * r , void * data , ngx_int_t rc )
656
656
{
657
- child_request_context_t * ctx ;
657
+ ngx_child_request_context_t * ctx ;
658
658
ngx_http_upstream_t * u ;
659
659
660
660
ctx = ngx_http_get_module_ctx (r , ngx_http_vod_module );
@@ -664,21 +664,21 @@ child_request_finished_handler(ngx_http_request_t *r, void *data, ngx_int_t rc)
664
664
}
665
665
666
666
ngx_log_debug2 (NGX_LOG_DEBUG_HTTP , r -> connection -> log , 0 ,
667
- "child_request_finished_handler : called rc=%i, r=%p" , rc , r );
667
+ "ngx_child_request_finished_handler : called rc=%i, r=%p" , rc , r );
668
668
669
669
u = r -> upstream ;
670
670
if (rc == NGX_OK )
671
671
{
672
672
if (u -> state && u -> state -> status != NGX_HTTP_OK && u -> state -> status != NGX_HTTP_PARTIAL_CONTENT )
673
673
{
674
674
ngx_log_error (NGX_LOG_ERR , r -> connection -> log , 0 ,
675
- "child_request_finished_handler : upstream returned a bad status %ui" , u -> state -> status );
675
+ "ngx_child_request_finished_handler : upstream returned a bad status %ui" , u -> state -> status );
676
676
rc = NGX_HTTP_BAD_GATEWAY ;
677
677
}
678
678
else if (u -> length != 0 )
679
679
{
680
680
ngx_log_error (NGX_LOG_ERR , r -> connection -> log , 0 ,
681
- "child_request_finished_handler : upstream connection was closed with %O bytes left to read" , u -> length );
681
+ "ngx_child_request_finished_handler : upstream connection was closed with %O bytes left to read" , u -> length );
682
682
rc = NGX_HTTP_BAD_GATEWAY ;
683
683
}
684
684
}
@@ -691,18 +691,18 @@ child_request_finished_handler(ngx_http_request_t *r, void *data, ngx_int_t rc)
691
691
692
692
// Note: must not return positive error codes (like NGX_HTTP_INTERNAL_SERVER_ERROR)
693
693
ngx_int_t
694
- child_request_start (
694
+ ngx_child_request_start (
695
695
ngx_http_request_t * r ,
696
- child_request_buffers_t * buffers ,
697
- child_request_callback_t callback ,
696
+ ngx_child_request_buffers_t * buffers ,
697
+ ngx_child_request_callback_t callback ,
698
698
void * callback_context ,
699
699
ngx_http_upstream_conf_t * upstream_conf ,
700
700
ngx_str_t * internal_location ,
701
- child_request_params_t * params ,
701
+ ngx_child_request_params_t * params ,
702
702
off_t max_response_length ,
703
703
u_char * response_buffer )
704
704
{
705
- child_request_context_t * child_ctx ;
705
+ ngx_child_request_context_t * child_ctx ;
706
706
ngx_http_post_subrequest_t * psr ;
707
707
ngx_http_request_t * sr ;
708
708
ngx_str_t args = ngx_null_string ;
@@ -723,17 +723,17 @@ child_request_start(
723
723
if (buffers -> headers_buffer == NULL )
724
724
{
725
725
ngx_log_debug0 (NGX_LOG_DEBUG_HTTP , r -> connection -> log , 0 ,
726
- "child_request_start : ngx_palloc failed (1)" );
726
+ "ngx_child_request_start : ngx_palloc failed (1)" );
727
727
return NGX_ERROR ;
728
728
}
729
729
}
730
730
731
731
// initialize the request buffer
732
- buffers -> request_buffer = init_request_buffer (r , buffers -> request_buffer , params );
732
+ buffers -> request_buffer = ngx_init_request_buffer (r , buffers -> request_buffer , params );
733
733
if (buffers -> request_buffer == NULL )
734
734
{
735
735
ngx_log_debug0 (NGX_LOG_DEBUG_HTTP , r -> connection -> log , 0 ,
736
- "child_request_start: init_request_buffer failed" );
736
+ "ngx_child_request_start: ngx_init_request_buffer failed" );
737
737
return NGX_ERROR ;
738
738
}
739
739
@@ -742,7 +742,7 @@ child_request_start(
742
742
if (child_ctx == NULL )
743
743
{
744
744
ngx_log_debug0 (NGX_LOG_DEBUG_HTTP , r -> connection -> log , 0 ,
745
- "child_request_start : ngx_pcalloc failed" );
745
+ "ngx_child_request_start : ngx_pcalloc failed" );
746
746
return NGX_ERROR ;
747
747
}
748
748
@@ -762,7 +762,7 @@ child_request_start(
762
762
if (uri .data == NULL )
763
763
{
764
764
ngx_log_debug0 (NGX_LOG_DEBUG_HTTP , r -> connection -> log , 0 ,
765
- "child_request_start : ngx_palloc failed (2)" );
765
+ "ngx_child_request_start : ngx_palloc failed (2)" );
766
766
return NGX_ERROR ;
767
767
}
768
768
p = ngx_copy (uri .data , internal_location -> data , internal_location -> len );
@@ -775,32 +775,32 @@ child_request_start(
775
775
if (psr == NULL )
776
776
{
777
777
ngx_log_debug0 (NGX_LOG_DEBUG_HTTP , r -> connection -> log , 0 ,
778
- "child_request_start : ngx_palloc failed (3)" );
778
+ "ngx_child_request_start : ngx_palloc failed (3)" );
779
779
return NGX_ERROR ;
780
780
}
781
781
782
- psr -> handler = child_request_finished_handler ;
782
+ psr -> handler = ngx_child_request_finished_handler ;
783
783
psr -> data = r ;
784
784
785
785
rc = ngx_http_subrequest (r , & uri , & args , & sr , psr , NGX_HTTP_SUBREQUEST_WAITED | NGX_HTTP_SUBREQUEST_IN_MEMORY );
786
786
if (rc == NGX_ERROR )
787
787
{
788
788
ngx_log_error (NGX_LOG_ERR , r -> connection -> log , 0 ,
789
- "child_request_start : ngx_http_subrequest failed %i" , rc );
789
+ "ngx_child_request_start : ngx_http_subrequest failed %i" , rc );
790
790
return rc ;
791
791
}
792
792
793
793
// set the context of the subrequest
794
794
ngx_http_set_ctx (sr , child_ctx , ngx_http_vod_module );
795
795
796
796
ngx_log_debug1 (NGX_LOG_DEBUG_HTTP , r -> connection -> log , 0 ,
797
- "child_request_start : completed successfully sr=%p" , sr );
797
+ "ngx_child_request_start : completed successfully sr=%p" , sr );
798
798
799
799
return NGX_AGAIN ;
800
800
}
801
801
802
802
void
803
- child_request_free_buffers (ngx_pool_t * pool , child_request_buffers_t * buffers )
803
+ ngx_child_request_free_buffers (ngx_pool_t * pool , ngx_child_request_buffers_t * buffers )
804
804
{
805
805
ngx_pfree (pool , buffers -> headers_buffer );
806
806
buffers -> headers_buffer = NULL ;
@@ -809,7 +809,7 @@ child_request_free_buffers(ngx_pool_t* pool, child_request_buffers_t* buffers)
809
809
}
810
810
811
811
void
812
- init_upstream_conf (ngx_http_upstream_conf_t * upstream )
812
+ ngx_init_upstream_conf (ngx_http_upstream_conf_t * upstream )
813
813
{
814
814
upstream -> connect_timeout = NGX_CONF_UNSET_MSEC ;
815
815
upstream -> send_timeout = NGX_CONF_UNSET_MSEC ;
@@ -836,7 +836,7 @@ init_upstream_conf(ngx_http_upstream_conf_t* upstream)
836
836
}
837
837
838
838
char *
839
- merge_upstream_conf (
839
+ ngx_merge_upstream_conf (
840
840
ngx_conf_t * cf ,
841
841
ngx_http_upstream_conf_t * conf_upstream ,
842
842
ngx_http_upstream_conf_t * prev_upstream )
0 commit comments