OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

546 lines
19 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../nginx/nginx_upload_module-2.2-branch-update-20111130.diff
  5. # Copyright (C) 2012 The OpenSDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This patch file is dual-licensed. It is available under the license the
  10. # patched project is licensed under, as long as it is an OpenSource license
  11. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  12. # of the GNU General Public License as published by the Free Software
  13. # Foundation; either version 2 of the License, or (at your option) any later
  14. # version.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. From 7990a22bca14b128ec865fca296fdf8924ff320f Mon Sep 17 00:00:00 2001
  17. From: Valery Kholodkov <valery@unimatrix1.(none)>
  18. Date: Tue, 14 Dec 2010 11:48:32 +0100
  19. Subject: [PATCH 1/6] A directive upload_add_header that allows to add headers to 201 Created responses
  20. ---
  21. ngx_http_upload_module.c | 134 ++++++++++++++++++++++++++++++++++++++++++++++
  22. 1 files changed, 134 insertions(+), 0 deletions(-)
  23. diff --git nginx-upload-module-2.2.0/ngx_http_upload_module.c nginx-upload-module-2.2-branch-update/ngx_http_upload_module.c
  24. index b95e12b..d762005 100644
  25. --- nginx-upload-module-2.2.0/ngx_http_upload_module.c
  26. +++ nginx-upload-module-2.2-branch-update/ngx_http_upload_module.c
  27. @@ -95,6 +95,14 @@ typedef struct {
  28. } ngx_http_upload_field_template_t;
  29. /*
  30. + * Template for a header
  31. + */
  32. +typedef struct {
  33. + ngx_http_complex_value_t *name;
  34. + ngx_http_complex_value_t *value;
  35. +} ngx_http_upload_header_template_t;
  36. +
  37. +/*
  38. * Filter for fields in output form
  39. */
  40. typedef struct {
  41. @@ -137,6 +145,7 @@ typedef struct {
  42. ngx_array_t *aggregate_field_templates;
  43. ngx_array_t *field_filters;
  44. ngx_array_t *cleanup_statuses;
  45. + ngx_array_t *header_templates;
  46. ngx_flag_t forward_args;
  47. ngx_flag_t tame_arrays;
  48. ngx_flag_t resumable_uploads;
  49. @@ -279,6 +288,8 @@ static ngx_int_t ngx_http_read_upload_client_request_body(ngx_http_request_t *r)
  50. static char *ngx_http_upload_set_form_field(ngx_conf_t *cf, ngx_command_t *cmd,
  51. void *conf);
  52. +static char *ngx_http_upload_add_header(ngx_conf_t *cf, ngx_command_t *cmd,
  53. + void *conf);
  54. static char *ngx_http_upload_pass_form_field(ngx_conf_t *cf, ngx_command_t *cmd,
  55. void *conf);
  56. static char *ngx_http_upload_cleanup(ngx_conf_t *cf, ngx_command_t *cmd,
  57. @@ -575,6 +586,17 @@ static ngx_command_t ngx_http_upload_commands[] = { /* {{{ */
  58. offsetof(ngx_http_upload_loc_conf_t, resumable_uploads),
  59. NULL },
  60. + /*
  61. + * Specifies the name and content of the header that will be added to the response
  62. + */
  63. + { ngx_string("upload_add_header"),
  64. + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LMT_CONF|NGX_HTTP_LIF_CONF
  65. + |NGX_CONF_TAKE2,
  66. + ngx_http_upload_add_header,
  67. + NGX_HTTP_LOC_CONF_OFFSET,
  68. + offsetof(ngx_http_upload_loc_conf_t, header_templates),
  69. + NULL},
  70. +
  71. ngx_null_command
  72. }; /* }}} */
  73. @@ -758,6 +780,42 @@ ngx_http_upload_handler(ngx_http_request_t *r)
  74. return NGX_DONE;
  75. } /* }}} */
  76. +static ngx_int_t ngx_http_upload_add_headers(ngx_http_request_t *r, ngx_http_upload_loc_conf_t *ulcf) { /* {{{ */
  77. + ngx_str_t name;
  78. + ngx_str_t value;
  79. + ngx_http_upload_header_template_t *t;
  80. + ngx_table_elt_t *h;
  81. + ngx_uint_t i;
  82. +
  83. + t = ulcf->header_templates->elts;
  84. + for(i = 0; i < ulcf->header_templates->nelts; i++) {
  85. + if(ngx_http_complex_value(r, t->name, &name) != NGX_OK) {
  86. + return NGX_ERROR;
  87. + }
  88. +
  89. + if(ngx_http_complex_value(r, t->value, &value) != NGX_OK) {
  90. + return NGX_ERROR;
  91. + }
  92. +
  93. + if(name.len != 0 && value.len != 0) {
  94. + h = ngx_list_push(&r->headers_out.headers);
  95. + if(h == NULL) {
  96. + return NGX_ERROR;
  97. + }
  98. +
  99. + h->hash = 1;
  100. + h->key.len = name.len;
  101. + h->key.data = name.data;
  102. + h->value.len = value.len;
  103. + h->value.data = value.data;
  104. + }
  105. +
  106. + t++;
  107. + }
  108. +
  109. + return NGX_OK;
  110. +} /* }}} */
  111. +
  112. static ngx_int_t ngx_http_upload_body_handler(ngx_http_request_t *r) { /* {{{ */
  113. ngx_http_upload_loc_conf_t *ulcf = ngx_http_get_module_loc_conf(r, ngx_http_upload_module);
  114. ngx_http_upload_ctx_t *ctx = ngx_http_get_module_ctx(r, ngx_http_upload_module);
  115. @@ -774,6 +832,10 @@ static ngx_int_t ngx_http_upload_body_handler(ngx_http_request_t *r) { /* {{{ */
  116. if(ctx->prevent_output) {
  117. r->headers_out.status = NGX_HTTP_CREATED;
  118. + if(ngx_http_upload_add_headers(r, ulcf) != NGX_OK) {
  119. + return NGX_HTTP_INTERNAL_SERVER_ERROR;
  120. + }
  121. +
  122. /*
  123. * Add range header and body
  124. */
  125. @@ -1809,6 +1871,7 @@ ngx_http_upload_create_loc_conf(ngx_conf_t *cf)
  126. conf->limit_rate = NGX_CONF_UNSET_SIZE;
  127. /*
  128. + * conf->header_templates,
  129. * conf->field_templates,
  130. * conf->aggregate_field_templates,
  131. * and conf->field_filters are
  132. @@ -1925,6 +1988,10 @@ ngx_http_upload_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
  133. conf->cleanup_statuses = prev->cleanup_statuses;
  134. }
  135. + if(conf->header_templates == NULL) {
  136. + conf->header_templates = prev->header_templates;
  137. + }
  138. +
  139. return NGX_CONF_OK;
  140. } /* }}} */
  141. @@ -2396,6 +2463,73 @@ ngx_http_upload_pass_form_field(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
  142. return NGX_CONF_OK;
  143. } /* }}} */
  144. +static char * /* {{{ ngx_http_upload_add_header */
  145. +ngx_http_upload_add_header(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
  146. +{
  147. + ngx_str_t *value;
  148. + ngx_http_upload_header_template_t *h;
  149. + ngx_array_t **field;
  150. + ngx_http_compile_complex_value_t ccv;
  151. +
  152. + field = (ngx_array_t**) (((u_char*)conf) + cmd->offset);
  153. +
  154. + value = cf->args->elts;
  155. +
  156. + /*
  157. + * Add new entry to header template list
  158. + */
  159. + if (*field == NULL) {
  160. + *field = ngx_array_create(cf->pool, 1,
  161. + sizeof(ngx_http_upload_header_template_t));
  162. + if (*field == NULL) {
  163. + return NGX_CONF_ERROR;
  164. + }
  165. + }
  166. +
  167. + h = ngx_array_push(*field);
  168. + if (h == NULL) {
  169. + return NGX_CONF_ERROR;
  170. + }
  171. +
  172. + /*
  173. + * Compile header name
  174. + */
  175. + h->name = ngx_palloc(cf->pool, sizeof(ngx_http_complex_value_t));
  176. + if(h->name == NULL) {
  177. + return NGX_CONF_ERROR;
  178. + }
  179. +
  180. + ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t));
  181. +
  182. + ccv.cf = cf;
  183. + ccv.value = &value[1];
  184. + ccv.complex_value = h->name;
  185. +
  186. + if (ngx_http_compile_complex_value(&ccv) != NGX_OK) {
  187. + return NGX_CONF_ERROR;
  188. + }
  189. +
  190. + /*
  191. + * Compile header value
  192. + */
  193. + h->value = ngx_palloc(cf->pool, sizeof(ngx_http_complex_value_t));
  194. + if(h->value == NULL) {
  195. + return NGX_CONF_ERROR;
  196. + }
  197. +
  198. + ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t));
  199. +
  200. + ccv.cf = cf;
  201. + ccv.value = &value[2];
  202. + ccv.complex_value = h->value;
  203. +
  204. + if (ngx_http_compile_complex_value(&ccv) != NGX_OK) {
  205. + return NGX_CONF_ERROR;
  206. + }
  207. +
  208. + return NGX_CONF_OK;
  209. +} /* }}} */
  210. +
  211. static char * /* {{{ ngx_http_upload_cleanup */
  212. ngx_http_upload_cleanup(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
  213. {
  214. --
  215. 1.6.6.2
  216. From 8a9d65c678b739c333343a3c2bb7d582f7f5e3b1 Mon Sep 17 00:00:00 2001
  217. From: Valery Kholodkov <valery@unimatrix1.(none)>
  218. Date: Tue, 14 Dec 2010 12:34:20 +0100
  219. Subject: [PATCH 2/6] A handler for OPTIONS method that facilitates HTML5 uploades
  220. ---
  221. ngx_http_upload_module.c | 26 ++++++++++++++++++++++++--
  222. 1 files changed, 24 insertions(+), 2 deletions(-)
  223. diff --git nginx-upload-module-2.2.0/ngx_http_upload_module.c nginx-upload-module-2.2-branch-update/ngx_http_upload_module.c
  224. index d762005..650bfea 100644
  225. --- nginx-upload-module-2.2.0/ngx_http_upload_module.c
  226. +++ nginx-upload-module-2.2-branch-update/ngx_http_upload_module.c
  227. @@ -243,6 +243,7 @@ typedef struct ngx_http_upload_ctx_s {
  228. } ngx_http_upload_ctx_t;
  229. static ngx_int_t ngx_http_upload_handler(ngx_http_request_t *r);
  230. +static ngx_int_t ngx_http_upload_options_handler(ngx_http_request_t *r);
  231. static ngx_int_t ngx_http_upload_body_handler(ngx_http_request_t *r);
  232. static void *ngx_http_upload_create_loc_conf(ngx_conf_t *cf);
  233. @@ -710,11 +711,14 @@ ngx_http_upload_handler(ngx_http_request_t *r)
  234. ngx_http_upload_ctx_t *u;
  235. ngx_int_t rc;
  236. + ulcf = ngx_http_get_module_loc_conf(r, ngx_http_upload_module);
  237. +
  238. + if((r->method & NGX_HTTP_OPTIONS) && ulcf->resumable_uploads)
  239. + return ngx_http_upload_options_handler(r);
  240. +
  241. if (!(r->method & NGX_HTTP_POST))
  242. return NGX_HTTP_NOT_ALLOWED;
  243. - ulcf = ngx_http_get_module_loc_conf(r, ngx_http_upload_module);
  244. -
  245. u = ngx_http_get_module_ctx(r, ngx_http_upload_module);
  246. if (u == NULL) {
  247. @@ -816,6 +820,24 @@ static ngx_int_t ngx_http_upload_add_headers(ngx_http_request_t *r, ngx_http_upl
  248. return NGX_OK;
  249. } /* }}} */
  250. +static ngx_int_t ngx_http_upload_options_handler(ngx_http_request_t *r) { /* {{{ */
  251. + ngx_http_upload_loc_conf_t *ulcf;
  252. +
  253. + ulcf = ngx_http_get_module_loc_conf(r, ngx_http_upload_module);
  254. +
  255. + r->headers_out.status = NGX_HTTP_OK;
  256. +
  257. + if(ngx_http_upload_add_headers(r, ulcf) != NGX_OK) {
  258. + return NGX_HTTP_INTERNAL_SERVER_ERROR;
  259. + }
  260. +
  261. + r->header_only = 1;
  262. + r->headers_out.content_length_n = 0;
  263. + r->allow_ranges = 0;
  264. +
  265. + return ngx_http_send_header(r);
  266. +} /* }}} */
  267. +
  268. static ngx_int_t ngx_http_upload_body_handler(ngx_http_request_t *r) { /* {{{ */
  269. ngx_http_upload_loc_conf_t *ulcf = ngx_http_get_module_loc_conf(r, ngx_http_upload_module);
  270. ngx_http_upload_ctx_t *ctx = ngx_http_get_module_ctx(r, ngx_http_upload_module);
  271. --
  272. 1.6.6.2
  273. From 1f9b976d08486c91c9b820ce9f427ac0f7a8d2e6 Mon Sep 17 00:00:00 2001
  274. From: Valery Kholodkov <valery@unimatrix1.(none)>
  275. Date: Tue, 14 Dec 2010 15:56:13 +0100
  276. Subject: [PATCH 3/6] Enable OPTIONS method processing for normal requests
  277. ---
  278. ngx_http_upload_module.c | 54 +++++++++++++++++++++++----------------------
  279. 1 files changed, 28 insertions(+), 26 deletions(-)
  280. diff --git nginx-upload-module-2.2.0/ngx_http_upload_module.c nginx-upload-module-2.2-branch-update/ngx_http_upload_module.c
  281. index 650bfea..cd60f29 100644
  282. --- nginx-upload-module-2.2.0/ngx_http_upload_module.c
  283. +++ nginx-upload-module-2.2-branch-update/ngx_http_upload_module.c
  284. @@ -711,14 +711,14 @@ ngx_http_upload_handler(ngx_http_request_t *r)
  285. ngx_http_upload_ctx_t *u;
  286. ngx_int_t rc;
  287. - ulcf = ngx_http_get_module_loc_conf(r, ngx_http_upload_module);
  288. -
  289. - if((r->method & NGX_HTTP_OPTIONS) && ulcf->resumable_uploads)
  290. + if(r->method & NGX_HTTP_OPTIONS)
  291. return ngx_http_upload_options_handler(r);
  292. if (!(r->method & NGX_HTTP_POST))
  293. return NGX_HTTP_NOT_ALLOWED;
  294. + ulcf = ngx_http_get_module_loc_conf(r, ngx_http_upload_module);
  295. +
  296. u = ngx_http_get_module_ctx(r, ngx_http_upload_module);
  297. if (u == NULL) {
  298. @@ -791,30 +791,32 @@ static ngx_int_t ngx_http_upload_add_headers(ngx_http_request_t *r, ngx_http_upl
  299. ngx_table_elt_t *h;
  300. ngx_uint_t i;
  301. - t = ulcf->header_templates->elts;
  302. - for(i = 0; i < ulcf->header_templates->nelts; i++) {
  303. - if(ngx_http_complex_value(r, t->name, &name) != NGX_OK) {
  304. - return NGX_ERROR;
  305. - }
  306. -
  307. - if(ngx_http_complex_value(r, t->value, &value) != NGX_OK) {
  308. - return NGX_ERROR;
  309. - }
  310. + if(ulcf->header_templates != NULL) {
  311. + t = ulcf->header_templates->elts;
  312. + for(i = 0; i < ulcf->header_templates->nelts; i++) {
  313. + if(ngx_http_complex_value(r, t->name, &name) != NGX_OK) {
  314. + return NGX_ERROR;
  315. + }
  316. - if(name.len != 0 && value.len != 0) {
  317. - h = ngx_list_push(&r->headers_out.headers);
  318. - if(h == NULL) {
  319. + if(ngx_http_complex_value(r, t->value, &value) != NGX_OK) {
  320. return NGX_ERROR;
  321. }
  322. - h->hash = 1;
  323. - h->key.len = name.len;
  324. - h->key.data = name.data;
  325. - h->value.len = value.len;
  326. - h->value.data = value.data;
  327. - }
  328. + if(name.len != 0 && value.len != 0) {
  329. + h = ngx_list_push(&r->headers_out.headers);
  330. + if(h == NULL) {
  331. + return NGX_ERROR;
  332. + }
  333. - t++;
  334. + h->hash = 1;
  335. + h->key.len = name.len;
  336. + h->key.data = name.data;
  337. + h->value.len = value.len;
  338. + h->value.data = value.data;
  339. + }
  340. +
  341. + t++;
  342. + }
  343. }
  344. return NGX_OK;
  345. @@ -851,13 +853,13 @@ static ngx_int_t ngx_http_upload_body_handler(ngx_http_request_t *r) { /* {{{ */
  346. ngx_str_t dummy = ngx_string("<ngx_upload_module_dummy>");
  347. ngx_table_elt_t *h;
  348. + if(ngx_http_upload_add_headers(r, ulcf) != NGX_OK) {
  349. + return NGX_HTTP_INTERNAL_SERVER_ERROR;
  350. + }
  351. +
  352. if(ctx->prevent_output) {
  353. r->headers_out.status = NGX_HTTP_CREATED;
  354. - if(ngx_http_upload_add_headers(r, ulcf) != NGX_OK) {
  355. - return NGX_HTTP_INTERNAL_SERVER_ERROR;
  356. - }
  357. -
  358. /*
  359. * Add range header and body
  360. */
  361. --
  362. 1.6.6.2
  363. From 5849956827b4246280e153d97a0a141eaaf9c5fa Mon Sep 17 00:00:00 2001
  364. From: Valery Kholodkov <valery@iva.(none)>
  365. Date: Tue, 1 Feb 2011 00:14:32 +0100
  366. Subject: [PATCH 4/6] Added directive upload_empty_field_names: allow passing fields with empty names to backend
  367. ---
  368. ngx_http_upload_module.c | 25 +++++++++++++++++++++++--
  369. 1 files changed, 23 insertions(+), 2 deletions(-)
  370. diff --git nginx-upload-module-2.2.0/ngx_http_upload_module.c nginx-upload-module-2.2-branch-update/ngx_http_upload_module.c
  371. index cd60f29..6e3c9c9 100644
  372. --- nginx-upload-module-2.2.0/ngx_http_upload_module.c
  373. +++ nginx-upload-module-2.2-branch-update/ngx_http_upload_module.c
  374. @@ -149,6 +149,7 @@ typedef struct {
  375. ngx_flag_t forward_args;
  376. ngx_flag_t tame_arrays;
  377. ngx_flag_t resumable_uploads;
  378. + ngx_flag_t empty_field_names;
  379. size_t limit_rate;
  380. unsigned int md5:1;
  381. @@ -587,6 +588,17 @@ static ngx_command_t ngx_http_upload_commands[] = { /* {{{ */
  382. offsetof(ngx_http_upload_loc_conf_t, resumable_uploads),
  383. NULL },
  384. + /*
  385. + * Specifies whether empty field names are allowed
  386. + */
  387. + { ngx_string("upload_empty_fiels_names"),
  388. + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LMT_CONF|NGX_HTTP_LIF_CONF
  389. + |NGX_CONF_FLAG,
  390. + ngx_conf_set_flag_slot,
  391. + NGX_HTTP_LOC_CONF_OFFSET,
  392. + offsetof(ngx_http_upload_loc_conf_t, empty_field_names),
  393. + NULL },
  394. +
  395. /*
  396. * Specifies the name and content of the header that will be added to the response
  397. */
  398. @@ -1236,7 +1248,10 @@ static ngx_int_t ngx_http_upload_start_handler(ngx_http_upload_ctx_t *u) { /* {{
  399. #if (NGX_PCRE)
  400. rc = ngx_regex_exec(f[i].regex, &u->field_name, NULL, 0);
  401. - if (rc != NGX_REGEX_NO_MATCHED && rc < 0) {
  402. + /* Modified by Naren to work around iMovie and Quicktime which send empty values Added: && u->field_name.len > 0 */
  403. + if ((ulcf->empty_field_names && rc != NGX_REGEX_NO_MATCHED && rc < 0 && u->field_name.len != 0)
  404. + || (!ulcf->empty_field_names && rc != NGX_REGEX_NO_MATCHED && rc < 0))
  405. + {
  406. return NGX_UPLOAD_SCRIPTERROR;
  407. }
  408. @@ -1252,7 +1267,7 @@ static ngx_int_t ngx_http_upload_start_handler(ngx_http_upload_ctx_t *u) { /* {{
  409. }
  410. }
  411. - if(pass_field && u->field_name.len > 0) {
  412. + if(pass_field && u->field_name.len != 0) {
  413. /*
  414. * Here we do a small hack: the content of a non-file field
  415. * is not known until ngx_http_upload_flush_output_buffer
  416. @@ -1885,6 +1900,7 @@ ngx_http_upload_create_loc_conf(ngx_conf_t *cf)
  417. conf->forward_args = NGX_CONF_UNSET;
  418. conf->tame_arrays = NGX_CONF_UNSET;
  419. conf->resumable_uploads = NGX_CONF_UNSET;
  420. + conf->empty_field_names = NGX_CONF_UNSET;
  421. conf->buffer_size = NGX_CONF_UNSET_SIZE;
  422. conf->merge_buffer_size = NGX_CONF_UNSET_SIZE;
  423. @@ -1984,6 +2000,11 @@ ngx_http_upload_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
  424. prev->resumable_uploads : 0;
  425. }
  426. + if(conf->empty_field_names == NGX_CONF_UNSET) {
  427. + conf->empty_field_names = (prev->empty_field_names != NGX_CONF_UNSET) ?
  428. + prev->empty_field_names : 0;
  429. + }
  430. +
  431. if(conf->field_templates == NULL) {
  432. conf->field_templates = prev->field_templates;
  433. }
  434. --
  435. 1.6.6.2
  436. From b100ed9971612c4f16279e188638b6bea1d9cb59 Mon Sep 17 00:00:00 2001
  437. From: Edward Dale <scompt@scompt.com>
  438. Date: Thu, 10 Feb 2011 15:50:06 +0100
  439. Subject: [PATCH 5/6] Allowing status codes as low as 200 to trigger cleanup.
  440. ---
  441. ngx_http_upload_module.c | 4 ++--
  442. 1 files changed, 2 insertions(+), 2 deletions(-)
  443. diff --git nginx-upload-module-2.2.0/ngx_http_upload_module.c nginx-upload-module-2.2-branch-update/ngx_http_upload_module.c
  444. index 6e3c9c9..3e1fcc5 100644
  445. --- nginx-upload-module-2.2.0/ngx_http_upload_module.c
  446. +++ nginx-upload-module-2.2-branch-update/ngx_http_upload_module.c
  447. @@ -2632,9 +2632,9 @@ ngx_http_upload_cleanup(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
  448. hi = lo = status;
  449. }
  450. - if (lo < 400 || hi > 599) {
  451. + if (lo < 200 || hi > 599) {
  452. ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
  453. - "value(s) \"%V\" must be between 400 and 599",
  454. + "value(s) \"%V\" must be between 200 and 599",
  455. &value[i]);
  456. return NGX_CONF_ERROR;
  457. }
  458. --
  459. 1.6.6.2
  460. From b18a0707e3aeaca8eb409ee6323d4c7abbe05d4b Mon Sep 17 00:00:00 2001
  461. From: Simon <bigplum@gmail.com>
  462. Date: Sat, 23 Apr 2011 17:39:33 +0800
  463. Subject: [PATCH 6/6] range length must equal to content length
  464. ---
  465. ngx_http_upload_module.c | 8 ++++++++
  466. 1 files changed, 8 insertions(+), 0 deletions(-)
  467. diff --git nginx-upload-module-2.2.0/ngx_http_upload_module.c nginx-upload-module-2.2-branch-update/ngx_http_upload_module.c
  468. index 3e1fcc5..01347c9 100644
  469. --- nginx-upload-module-2.2.0/ngx_http_upload_module.c
  470. +++ nginx-upload-module-2.2-branch-update/ngx_http_upload_module.c
  471. @@ -3478,6 +3478,14 @@ static ngx_int_t upload_parse_request_headers(ngx_http_upload_ctx_t *upload_ctx,
  472. return NGX_HTTP_REQUEST_ENTITY_TOO_LARGE;
  473. }
  474. + if( (upload_ctx->content_range_n.end - upload_ctx->content_range_n.start + 1)
  475. + != headers_in->content_length_n)
  476. + {
  477. + ngx_log_error(NGX_LOG_ERR, upload_ctx->log, 0,
  478. + "range length is not equal to content length");
  479. + return NGX_HTTP_RANGE_NOT_SATISFIABLE;
  480. + }
  481. +
  482. upload_ctx->partial_content = 1;
  483. }
  484. }
  485. --
  486. 1.6.6.2