|
|
@@ -99,11 +99,17 @@ 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
|
+
|
|
|
103
|
+static char *ngx_http_upload_progress_output_internal(
|
|
|
104
|
+ ngx_conf_t *cf, ngx_command_t *cmd, void *conf, ngx_uint_t multi,
|
|
|
105
|
+ ngx_str_t content_type, ngx_str_t *templates
|
|
|
106
|
+);
|
|
|
107
|
+static char *ngx_http_upload_progress_java_output(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
|
|
|
108
|
+static char *ngx_http_upload_progress_json_output(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
|
|
|
109
|
+static char *ngx_http_upload_progress_jsonp_output(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
|
|
|
110
|
+static char *ngx_http_upload_progress_json_multiple_output(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
|
|
|
111
|
+static char *ngx_http_upload_progress_jsonp_multiple_output(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
|
|
|
112
|
+
|
|
107
|
113
|
static void ngx_clean_old_connections(ngx_event_t * ev);
|
|
108
|
114
|
static ngx_int_t ngx_http_uploadprogress_content_handler(ngx_http_request_t *r);
|
|
109
|
115
|
|
|
|
@@ -1831,133 +1837,74 @@ ngx_http_upload_progress_template(ngx_conf_t * cf, ngx_command_t * cmd, void *co
|
|
1831
|
1837
|
}
|
|
1832
|
1838
|
|
|
1833
|
1839
|
static char*
|
|
1834
|
|
-ngx_http_upload_progress_java_output(ngx_conf_t * cf, ngx_command_t * cmd, void *conf)
|
|
1835
|
|
-{
|
|
|
1840
|
+ngx_http_upload_progress_output_internal(
|
|
|
1841
|
+ ngx_conf_t *cf, ngx_command_t *cmd, void *conf, ngx_uint_t multi,
|
|
|
1842
|
+ ngx_str_t content_type, ngx_str_t *templates
|
|
|
1843
|
+) {
|
|
1836
|
1844
|
ngx_http_uploadprogress_conf_t *upcf = conf;
|
|
1837
|
1845
|
ngx_http_uploadprogress_template_t *t;
|
|
1838
|
1846
|
ngx_uint_t i;
|
|
1839
|
1847
|
char* rc;
|
|
1840
|
1848
|
|
|
1841
|
|
- upcf->json_multiple = 0;
|
|
|
1849
|
+ upcf->json_multiple = multi;
|
|
1842
|
1850
|
|
|
1843
|
1851
|
t = (ngx_http_uploadprogress_template_t*)upcf->templates.elts;
|
|
1844
|
1852
|
|
|
1845
|
1853
|
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
|
|
-
|
|
|
1854
|
+ rc = ngx_http_upload_progress_set_template(cf, t + i, templates + i);
|
|
1849
|
1855
|
if (rc != NGX_CONF_OK) {
|
|
1850
|
1856
|
return rc;
|
|
1851
|
1857
|
}
|
|
1852
|
1858
|
}
|
|
1853
|
1859
|
|
|
1854
|
|
- upcf->content_type = (ngx_str_t)ngx_string("text/javascript");
|
|
|
1860
|
+ upcf->content_type = content_type;
|
|
1855
|
1861
|
|
|
1856
|
1862
|
return NGX_CONF_OK;
|
|
1857
|
1863
|
}
|
|
1858
|
1864
|
|
|
1859
|
1865
|
static char*
|
|
1860
|
|
-ngx_http_upload_progress_json_output(ngx_conf_t * cf, ngx_command_t * cmd, void *conf)
|
|
|
1866
|
+ngx_http_upload_progress_java_output(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|
1861
|
1867
|
{
|
|
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;
|
|
|
1868
|
+ return ngx_http_upload_progress_output_internal(
|
|
|
1869
|
+ cf, cmd, conf, 0,
|
|
|
1870
|
+ (ngx_str_t)ngx_string("text/javascript"),
|
|
|
1871
|
+ ngx_http_uploadprogress_java_defaults);
|
|
1883
|
1872
|
}
|
|
1884
|
1873
|
|
|
1885
|
1874
|
static char*
|
|
1886
|
|
-ngx_http_upload_progress_jsonp_output(ngx_conf_t * cf, ngx_command_t * cmd, void *conf)
|
|
|
1875
|
+ngx_http_upload_progress_json_output(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|
1887
|
1876
|
{
|
|
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;
|
|
|
1877
|
+ return ngx_http_upload_progress_output_internal(
|
|
|
1878
|
+ cf, cmd, conf, 0,
|
|
|
1879
|
+ (ngx_str_t)ngx_string("application/json"),
|
|
|
1880
|
+ ngx_http_uploadprogress_json_defaults);
|
|
1909
|
1881
|
}
|
|
1910
|
1882
|
|
|
1911
|
1883
|
static char*
|
|
1912
|
|
-ngx_http_upload_progress_json_multiple_output(ngx_conf_t * cf, ngx_command_t * cmd, void *conf)
|
|
|
1884
|
+ngx_http_upload_progress_jsonp_output(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|
1913
|
1885
|
{
|
|
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;
|
|
|
1886
|
+ return ngx_http_upload_progress_output_internal(
|
|
|
1887
|
+ cf, cmd, conf, 0,
|
|
|
1888
|
+ (ngx_str_t)ngx_string("application/javascript"),
|
|
|
1889
|
+ ngx_http_uploadprogress_jsonp_defaults);
|
|
1935
|
1890
|
}
|
|
1936
|
1891
|
|
|
1937
|
1892
|
static char*
|
|
1938
|
|
-ngx_http_upload_progress_jsonp_multiple_output(ngx_conf_t * cf, ngx_command_t * cmd, void *conf)
|
|
|
1893
|
+ngx_http_upload_progress_json_multiple_output(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|
1939
|
1894
|
{
|
|
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");
|
|
|
1895
|
+ return ngx_http_upload_progress_output_internal(
|
|
|
1896
|
+ cf, cmd, conf, 1,
|
|
|
1897
|
+ (ngx_str_t)ngx_string("application/json"),
|
|
|
1898
|
+ ngx_http_uploadprogress_json_multiple_defaults);
|
|
|
1899
|
+}
|
|
1959
|
1900
|
|
|
1960
|
|
- return NGX_CONF_OK;
|
|
|
1901
|
+static char*
|
|
|
1902
|
+ngx_http_upload_progress_jsonp_multiple_output(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|
|
1903
|
+{
|
|
|
1904
|
+ return ngx_http_upload_progress_output_internal(
|
|
|
1905
|
+ cf, cmd, conf, 1,
|
|
|
1906
|
+ (ngx_str_t)ngx_string("application/json"),
|
|
|
1907
|
+ ngx_http_uploadprogress_jsonp_multiple_defaults);
|
|
1961
|
1908
|
}
|
|
1962
|
1909
|
|
|
1963
|
1910
|
static ngx_int_t ngx_http_uploadprogress_received_variable(ngx_http_request_t *r,
|