@@ -3685,50 +3685,51 @@ ngx_stream_upsync_show_upstream(ngx_stream_upstream_srv_conf_t *uscf, ngx_buf_t
3685
3685
static void
3686
3686
ngx_stream_upsync_show (ngx_stream_session_t * s )
3687
3687
{
3688
- ngx_buf_t * b ;
3689
- ngx_uint_t i ;
3690
- ngx_stream_upstream_srv_conf_t * * uscfp = NULL ;
3691
- ngx_stream_upstream_main_conf_t * umcf ;
3688
+ ngx_buf_t * b_header , * b_body ;
3689
+ ngx_uint_t i ;
3690
+ ngx_stream_upstream_srv_conf_t * * uscfp = NULL ;
3691
+ ngx_stream_upstream_main_conf_t * umcf ;
3692
3692
3693
3693
umcf = ngx_stream_cycle_get_module_main_conf (ngx_cycle ,
3694
3694
ngx_stream_upstream_module );
3695
3695
3696
3696
uscfp = umcf -> upstreams .elts ;
3697
3697
3698
- b = ngx_create_temp_buf (s -> connection -> pool ,
3699
- NGX_PAGE_SIZE * NGX_PAGE_NUMBER );
3700
- if (b == NULL ) {
3698
+ b_header = ngx_create_temp_buf (s -> connection -> pool , NGX_PAGE_SIZE );
3699
+ b_body = ngx_create_temp_buf (s -> connection -> pool ,
3700
+ NGX_PAGE_SIZE * NGX_PAGE_NUMBER );
3701
+ if (b_header == NULL || b_body == NULL ) {
3701
3702
ngx_log_error (NGX_LOG_ERR , s -> connection -> log , 0 ,
3702
3703
"alloc upsync_show buf failed" );
3703
3704
3704
3705
ngx_stream_close_connection (s -> connection );
3705
3706
return ;
3706
3707
}
3707
3708
3708
- //HTTP Header
3709
- b -> last = ngx_snprintf (b -> last , b -> end - b -> last ,
3710
- "HTTP/1.0 200 OK\r\n" );
3711
- b -> last = ngx_snprintf (b -> last , b -> end - b -> last ,
3712
- "Server: nginx\r\n" );
3713
- b -> last = ngx_snprintf (b -> last , b -> end - b -> last ,
3714
- "Content-Type: text/plain\r\n" );
3715
- b -> last = ngx_snprintf (b -> last , b -> end - b -> last ,
3716
- "Connection: close\r\n\r\n" );
3717
-
3718
- ngx_stream_upsync_show_send (s , b ); //send header
3719
-
3720
- b -> pos = b -> last ;
3721
3709
if (umcf -> upstreams .nelts == 0 ) {
3722
- b -> last = ngx_snprintf (b -> last , b -> end - b -> last ,
3723
- "No upstreams defined\n" );
3710
+ b_body -> last = ngx_snprintf (b_body -> last , b_body -> end - b_body -> last ,
3711
+ "No upstreams defined\n" );
3724
3712
}
3725
3713
3726
3714
for (i = 0 ; i < umcf -> upstreams .nelts ; i ++ ) {
3727
- ngx_stream_upsync_show_upstream (uscfp [i ], b );
3728
- b -> last = ngx_snprintf (b -> last , b -> end - b -> last , "\n" );
3715
+ ngx_stream_upsync_show_upstream (uscfp [i ], b_body );
3716
+ b_body -> last = ngx_snprintf (b_body -> last , b_body -> end - b_body -> last , "\n" );
3729
3717
}
3730
3718
3731
- ngx_stream_upsync_show_send (s , b ); //send body
3719
+ //HTTP Header
3720
+ b_header -> last = ngx_snprintf (b_header -> last , b_header -> end - b_header -> last ,
3721
+ "HTTP/1.0 200 OK\r\n" );
3722
+ b_header -> last = ngx_snprintf (b_header -> last , b_header -> end - b_header -> last ,
3723
+ "Server: nginx\r\n" );
3724
+ b_header -> last = ngx_snprintf (b_header -> last , b_header -> end - b_header -> last ,
3725
+ "Content-Type: text/plain\r\n" );
3726
+ b_header -> last = ngx_snprintf (b_header -> last , b_header -> end - b_header -> last ,
3727
+ "Content-Length: %d\r\n" , b_body -> last - b_body -> pos );
3728
+ b_header -> last = ngx_snprintf (b_header -> last , b_header -> end - b_header -> last ,
3729
+ "Connection: close\r\n\r\n" );
3730
+
3731
+ ngx_stream_upsync_show_send (s , b_header ); //send header
3732
+ ngx_stream_upsync_show_send (s , b_body ); //send body
3732
3733
3733
3734
ngx_stream_close_connection (s -> connection );
3734
3735
0 commit comments