@@ -99,11 +99,12 @@ static char *ngx_http_track_uploads(ngx_conf_t * cf, ngx_command_t * cmd, void *
99
99
static char * ngx_http_report_uploads (ngx_conf_t * cf , ngx_command_t * cmd , void * conf );
100
100
static char * ngx_http_upload_progress (ngx_conf_t * cf , ngx_command_t * cmd , void * conf );
101
101
static char * ngx_http_upload_progress_template (ngx_conf_t * cf , ngx_command_t * cmd , void * conf );
102
- static char * ngx_http_upload_progress_java_output (ngx_conf_t * cf , ngx_command_t * cmd , void * conf );
103
- static char * ngx_http_upload_progress_json_output (ngx_conf_t * cf , ngx_command_t * cmd , void * conf );
104
- static char * ngx_http_upload_progress_jsonp_output (ngx_conf_t * cf , ngx_command_t * cmd , void * conf );
105
- static char * ngx_http_upload_progress_json_multiple_output (ngx_conf_t * cf , ngx_command_t * cmd , void * conf );
106
- static char * ngx_http_upload_progress_jsonp_multiple_output (ngx_conf_t * cf , ngx_command_t * cmd , void * conf );
102
+ static char * ngx_http_upload_progress_output_internal (ngx_conf_t * cf , ngx_command_t * cmd , void * conf );
103
+ static char * ngx_http_upload_progress_java_output (ngx_conf_t * cf , ngx_command_t * cmd , void * conf );
104
+ static char * ngx_http_upload_progress_json_output (ngx_conf_t * cf , ngx_command_t * cmd , void * conf );
105
+ static char * ngx_http_upload_progress_jsonp_output (ngx_conf_t * cf , ngx_command_t * cmd , void * conf );
106
+ static char * ngx_http_upload_progress_json_multiple_output (ngx_conf_t * cf , ngx_command_t * cmd , void * conf );
107
+ static char * ngx_http_upload_progress_jsonp_multiple_output (ngx_conf_t * cf , ngx_command_t * cmd , void * conf );
107
108
static void ngx_clean_old_connections (ngx_event_t * ev );
108
109
static ngx_int_t ngx_http_uploadprogress_content_handler (ngx_http_request_t * r );
109
110
@@ -1831,133 +1832,74 @@ ngx_http_upload_progress_template(ngx_conf_t * cf, ngx_command_t * cmd, void *co
1831
1832
}
1832
1833
1833
1834
static char *
1834
- ngx_http_upload_progress_java_output (ngx_conf_t * cf , ngx_command_t * cmd , void * conf )
1835
- {
1835
+ ngx_http_upload_progress_output_internal (
1836
+ ngx_conf_t * cf , ngx_command_t * cmd , void * conf , ngx_uint_t multi ,
1837
+ ngx_str_t content_type , ngx_str_t * templates
1838
+ ) {
1836
1839
ngx_http_uploadprogress_conf_t * upcf = conf ;
1837
1840
ngx_http_uploadprogress_template_t * t ;
1838
1841
ngx_uint_t i ;
1839
1842
char * rc ;
1840
1843
1841
- upcf -> json_multiple = 0 ;
1844
+ upcf -> json_multiple = multi ;
1842
1845
1843
1846
t = (ngx_http_uploadprogress_template_t * )upcf -> templates .elts ;
1844
1847
1845
1848
for (i = 0 ; i < upcf -> templates .nelts ; i ++ ) {
1846
- rc = ngx_http_upload_progress_set_template (
1847
- cf , t + i , ngx_http_uploadprogress_java_defaults + i );
1848
-
1849
+ rc = ngx_http_upload_progress_set_template (cf , t + i , templates + i );
1849
1850
if (rc != NGX_CONF_OK ) {
1850
1851
return rc ;
1851
1852
}
1852
1853
}
1853
1854
1854
- upcf -> content_type = ( ngx_str_t ) ngx_string ( "text/javascript" ) ;
1855
+ upcf -> content_type = content_type ;
1855
1856
1856
1857
return NGX_CONF_OK ;
1857
1858
}
1858
1859
1859
1860
static char *
1860
- ngx_http_upload_progress_json_output (ngx_conf_t * cf , ngx_command_t * cmd , void * conf )
1861
+ ngx_http_upload_progress_java_output (ngx_conf_t * cf , ngx_command_t * cmd , void * conf )
1861
1862
{
1862
- ngx_http_uploadprogress_conf_t * upcf = conf ;
1863
- ngx_http_uploadprogress_template_t * t ;
1864
- ngx_uint_t i ;
1865
- char * rc ;
1866
-
1867
- upcf -> json_multiple = 0 ;
1868
-
1869
- t = (ngx_http_uploadprogress_template_t * )upcf -> templates .elts ;
1870
-
1871
- for (i = 0 ; i < upcf -> templates .nelts ; i ++ ) {
1872
- rc = ngx_http_upload_progress_set_template (
1873
- cf , t + i , ngx_http_uploadprogress_json_defaults + i );
1874
-
1875
- if (rc != NGX_CONF_OK ) {
1876
- return rc ;
1877
- }
1878
- }
1879
-
1880
- upcf -> content_type = (ngx_str_t )ngx_string ("application/json" );
1881
-
1882
- return NGX_CONF_OK ;
1863
+ return ngx_http_upload_progress_output_internal (
1864
+ cf , cmd , conf , 0 ,
1865
+ (ngx_str_t )ngx_string ("text/javascript" ),
1866
+ ngx_http_uploadprogress_java_defaults );
1883
1867
}
1884
1868
1885
1869
static char *
1886
- ngx_http_upload_progress_jsonp_output (ngx_conf_t * cf , ngx_command_t * cmd , void * conf )
1870
+ ngx_http_upload_progress_json_output (ngx_conf_t * cf , ngx_command_t * cmd , void * conf )
1887
1871
{
1888
- ngx_http_uploadprogress_conf_t * upcf = conf ;
1889
- ngx_http_uploadprogress_template_t * t ;
1890
- ngx_uint_t i ;
1891
- char * rc ;
1892
-
1893
- upcf -> json_multiple = 0 ;
1894
-
1895
- t = (ngx_http_uploadprogress_template_t * )upcf -> templates .elts ;
1896
-
1897
- for (i = 0 ; i < upcf -> templates .nelts ; i ++ ) {
1898
- rc = ngx_http_upload_progress_set_template (
1899
- cf , t + i , ngx_http_uploadprogress_jsonp_defaults + i );
1900
-
1901
- if (rc != NGX_CONF_OK ) {
1902
- return rc ;
1903
- }
1904
- }
1905
-
1906
- upcf -> content_type = (ngx_str_t )ngx_string ("application/javascript" );
1907
-
1908
- return NGX_CONF_OK ;
1872
+ return ngx_http_upload_progress_output_internal (
1873
+ cf , cmd , conf , 0 ,
1874
+ (ngx_str_t )ngx_string ("application/json" ),
1875
+ ngx_http_uploadprogress_json_defaults );
1909
1876
}
1910
1877
1911
1878
static char *
1912
- ngx_http_upload_progress_json_multiple_output (ngx_conf_t * cf , ngx_command_t * cmd , void * conf )
1879
+ ngx_http_upload_progress_jsonp_output (ngx_conf_t * cf , ngx_command_t * cmd , void * conf )
1913
1880
{
1914
- ngx_http_uploadprogress_conf_t * upcf = conf ;
1915
- ngx_http_uploadprogress_template_t * t ;
1916
- ngx_uint_t i ;
1917
- char * rc ;
1918
-
1919
- upcf -> json_multiple = 1 ;
1920
-
1921
- t = (ngx_http_uploadprogress_template_t * )upcf -> templates .elts ;
1922
-
1923
- for (i = 0 ; i < upcf -> templates .nelts ; i ++ ) {
1924
- rc = ngx_http_upload_progress_set_template (
1925
- cf , t + i , ngx_http_uploadprogress_json_multiple_defaults + i );
1926
-
1927
- if (rc != NGX_CONF_OK ) {
1928
- return rc ;
1929
- }
1930
- }
1931
-
1932
- upcf -> content_type = (ngx_str_t )ngx_string ("application/json" );
1933
-
1934
- return NGX_CONF_OK ;
1881
+ return ngx_http_upload_progress_output_internal (
1882
+ cf , cmd , conf , 0 ,
1883
+ (ngx_str_t )ngx_string ("application/javascript" ),
1884
+ ngx_http_uploadprogress_jsonp_defaults );
1935
1885
}
1936
1886
1937
1887
static char *
1938
- ngx_http_upload_progress_jsonp_multiple_output (ngx_conf_t * cf , ngx_command_t * cmd , void * conf )
1888
+ ngx_http_upload_progress_json_multiple_output (ngx_conf_t * cf , ngx_command_t * cmd , void * conf )
1939
1889
{
1940
- ngx_http_uploadprogress_conf_t * upcf = conf ;
1941
- ngx_http_uploadprogress_template_t * t ;
1942
- ngx_uint_t i ;
1943
- char * rc ;
1944
-
1945
- upcf -> json_multiple = 1 ;
1946
-
1947
- t = (ngx_http_uploadprogress_template_t * )upcf -> templates .elts ;
1948
-
1949
- for (i = 0 ; i < upcf -> templates .nelts ; i ++ ) {
1950
- rc = ngx_http_upload_progress_set_template (
1951
- cf , t + i , ngx_http_uploadprogress_jsonp_multiple_defaults + i );
1952
-
1953
- if (rc != NGX_CONF_OK ) {
1954
- return rc ;
1955
- }
1956
- }
1957
-
1958
- upcf -> content_type = (ngx_str_t )ngx_string ("application/json" );
1890
+ return ngx_http_upload_progress_output_internal (
1891
+ cf , cmd , conf , 1 ,
1892
+ (ngx_str_t )ngx_string ("application/json" ),
1893
+ ngx_http_uploadprogress_json_multiple_defaults );
1894
+ }
1959
1895
1960
- return NGX_CONF_OK ;
1896
+ static char *
1897
+ ngx_http_upload_progress_jsonp_multiple_output (ngx_conf_t * cf , ngx_command_t * cmd , void * conf )
1898
+ {
1899
+ return ngx_http_upload_progress_output_internal (
1900
+ cf , cmd , conf , 1 ,
1901
+ (ngx_str_t )ngx_string ("application/json" ),
1902
+ ngx_http_uploadprogress_jsonp_multiple_defaults );
1961
1903
}
1962
1904
1963
1905
static ngx_int_t ngx_http_uploadprogress_received_variable (ngx_http_request_t * r ,
0 commit comments