|
|
@@ -311,18 +311,17 @@ static ngx_str_t ngx_http_uploadprogress_jsonp_multiple_defaults[] = {
|
|
311
|
311
|
static ngx_array_t ngx_http_uploadprogress_global_templates;
|
|
312
|
312
|
|
|
313
|
313
|
static ngx_str_t*
|
|
314
|
|
-get_tracking_id(ngx_http_request_t * r)
|
|
|
314
|
+get_tracking_id_internal(ngx_http_request_t *r, ngx_str_t *header_ref, const char *caller, bool multi)
|
|
315
|
315
|
{
|
|
316
|
316
|
u_char *p, *start_p;
|
|
317
|
317
|
ngx_uint_t i;
|
|
318
|
318
|
ngx_list_part_t *part;
|
|
319
|
319
|
ngx_table_elt_t *header;
|
|
320
|
320
|
ngx_str_t *ret, args;
|
|
321
|
|
- ngx_http_uploadprogress_conf_t *upcf;
|
|
322
|
321
|
|
|
323
|
|
- upcf = ngx_http_get_module_loc_conf(r, ngx_http_uploadprogress_module);
|
|
|
322
|
+ (void)multi;
|
|
324
|
323
|
|
|
325
|
|
- ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "upload-progress: get_tracking_id");
|
|
|
324
|
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "upload-progress: %s", caller);
|
|
326
|
325
|
|
|
327
|
326
|
part = &r->headers_in.headers.part;
|
|
328
|
327
|
header = part->elts;
|
|
|
@@ -340,19 +339,19 @@ get_tracking_id(ngx_http_request_t * r)
|
|
340
|
339
|
}
|
|
341
|
340
|
|
|
342
|
341
|
if (
|
|
343
|
|
- header[i].key.len == upcf->header.len &&
|
|
344
|
|
- ngx_strncasecmp(header[i].key.data, upcf->header.data, header[i].key.len) == 0
|
|
|
342
|
+ header[i].key.len == header_ref->len &&
|
|
|
343
|
+ ngx_strncasecmp(header[i].key.data, header_ref->data, header[i].key.len) == 0
|
|
345
|
344
|
) {
|
|
346
|
345
|
ret = ngx_calloc(sizeof(ngx_str_t), r->connection->log );
|
|
347
|
346
|
*ret = header[i].value;
|
|
348
|
347
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
349
|
|
- "upload-progress: get_tracking_id found header: %V", ret);
|
|
|
348
|
+ "upload-progress: %s: found header: %V", caller, ret);
|
|
350
|
349
|
return ret;
|
|
351
|
350
|
}
|
|
352
|
351
|
}
|
|
353
|
352
|
|
|
354
|
353
|
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
355
|
|
- "upload-progress: get_tracking_id no header found");
|
|
|
354
|
+ "upload-progress: %s: no header found", caller);
|
|
356
|
355
|
|
|
357
|
356
|
/* not found, check as a request arg */
|
|
358
|
357
|
/* it is possible the request args have not been yet created (or already released) */
|
|
|
@@ -361,18 +360,18 @@ get_tracking_id(ngx_http_request_t * r)
|
|
361
|
360
|
|
|
362
|
361
|
if (args.len && args.data) {
|
|
363
|
362
|
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
364
|
|
- "upload-progress: get_tracking_id no header found, args found");
|
|
|
363
|
+ "upload-progress: %s: no header found, args found", caller);
|
|
365
|
364
|
i = 0;
|
|
366
|
365
|
p = args.data;
|
|
367
|
366
|
do {
|
|
368
|
367
|
ngx_uint_t len = args.len - (p - args.data);
|
|
369
|
368
|
if (
|
|
370
|
|
- len >= (upcf->header.len + 1) &&
|
|
371
|
|
- ngx_strncasecmp(p, upcf->header.data, upcf->header.len) == 0 &&
|
|
372
|
|
- p[upcf->header.len] == '='
|
|
|
369
|
+ len >= (header_ref->len + 1) &&
|
|
|
370
|
+ ngx_strncasecmp(p, header_ref->data, header_ref->len) == 0 &&
|
|
|
371
|
+ p[header_ref->len] == '='
|
|
373
|
372
|
) {
|
|
374
|
373
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
375
|
|
- "upload-progress: get_tracking_id found args: %s",p);
|
|
|
374
|
+ "upload-progress: %s: found args: %s", caller, p);
|
|
376
|
375
|
i = 1;
|
|
377
|
376
|
break;
|
|
378
|
377
|
}
|
|
|
@@ -380,7 +379,7 @@ get_tracking_id(ngx_http_request_t * r)
|
|
380
|
379
|
} while (len > 0);
|
|
381
|
380
|
|
|
382
|
381
|
if (i) {
|
|
383
|
|
- start_p = p += upcf->header.len + 1;
|
|
|
382
|
+ start_p = p += header_ref->len + 1;
|
|
384
|
383
|
while (p < args.data + args.len) {
|
|
385
|
384
|
if (*(++p) == '&') {
|
|
386
|
385
|
break;
|
|
|
@@ -391,105 +390,34 @@ get_tracking_id(ngx_http_request_t * r)
|
|
391
|
390
|
ret->data = start_p;
|
|
392
|
391
|
ret->len = p - start_p;
|
|
393
|
392
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
394
|
|
- "upload-progress: get_tracking_id found args: %V",ret);
|
|
|
393
|
+ "upload-progress: %s: found args: %V", caller, ret);
|
|
395
|
394
|
return ret;
|
|
396
|
395
|
}
|
|
397
|
396
|
}
|
|
398
|
397
|
|
|
399
|
398
|
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
400
|
|
- "upload-progress: get_tracking_id no id found");
|
|
|
399
|
+ "upload-progress: %s: no id found", caller);
|
|
401
|
400
|
return NULL;
|
|
402
|
401
|
}
|
|
403
|
402
|
|
|
404
|
403
|
static ngx_str_t*
|
|
405
|
|
-get_tracking_ids_mul(ngx_http_request_t * r)
|
|
|
404
|
+get_tracking_id(ngx_http_request_t *r)
|
|
406
|
405
|
{
|
|
407
|
|
- u_char *p, *start_p;
|
|
408
|
|
- ngx_uint_t i;
|
|
409
|
|
- ngx_list_part_t *part;
|
|
410
|
|
- ngx_table_elt_t *header;
|
|
411
|
|
- ngx_str_t *ret, args;
|
|
412
|
|
- ngx_http_uploadprogress_conf_t *upcf;
|
|
|
406
|
+ ngx_http_uploadprogress_conf_t *upcf;
|
|
413
|
407
|
|
|
414
|
408
|
upcf = ngx_http_get_module_loc_conf(r, ngx_http_uploadprogress_module);
|
|
415
|
409
|
|
|
416
|
|
- ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "upload-progress: get_tracking_ids");
|
|
417
|
|
-
|
|
418
|
|
- part = &r->headers_in.headers.part;
|
|
419
|
|
- header = part->elts;
|
|
420
|
|
-
|
|
421
|
|
- for (i = 0; /* void */; i++) {
|
|
422
|
|
-
|
|
423
|
|
- if (i >= part->nelts) {
|
|
424
|
|
- if (part->next == NULL) {
|
|
425
|
|
- break;
|
|
426
|
|
- }
|
|
427
|
|
-
|
|
428
|
|
- part = part->next;
|
|
429
|
|
- header = part->elts;
|
|
430
|
|
- i = 0;
|
|
431
|
|
- }
|
|
432
|
|
-
|
|
433
|
|
- if (
|
|
434
|
|
- header[i].key.len == upcf->header_mul.len &&
|
|
435
|
|
- ngx_strncasecmp(header[i].key.data, upcf->header_mul.data, header[i].key.len) == 0
|
|
436
|
|
- ) {
|
|
437
|
|
- ret = ngx_calloc(sizeof(ngx_str_t), r->connection->log);
|
|
438
|
|
- *ret = header[i].value;
|
|
439
|
|
- ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
440
|
|
- "upload-progress: get_tracking_ids found header: %V", ret);
|
|
441
|
|
- return ret;
|
|
442
|
|
- }
|
|
443
|
|
- }
|
|
444
|
|
-
|
|
445
|
|
- ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
446
|
|
- "upload-progress: get_tracking_ids no header found");
|
|
447
|
|
-
|
|
448
|
|
- /* not found, check as a request arg */
|
|
449
|
|
- /* it is possible the request args have not been yet created (or already released) */
|
|
450
|
|
- /* so let's try harder first from the request line */
|
|
451
|
|
- args = r->args;
|
|
452
|
|
-
|
|
453
|
|
- if (args.len && args.data) {
|
|
454
|
|
- ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
455
|
|
- "upload-progress: get_tracking_id no header found, args found");
|
|
456
|
|
- i = 0;
|
|
457
|
|
- p = args.data;
|
|
458
|
|
- do {
|
|
459
|
|
- ngx_uint_t len = args.len - (p - args.data);
|
|
460
|
|
- if (
|
|
461
|
|
- len >= (upcf->header_mul.len + 1) &&
|
|
462
|
|
- ngx_strncasecmp(p, upcf->header_mul.data, upcf->header_mul.len) == 0 &&
|
|
463
|
|
- p[upcf->header_mul.len] == '='
|
|
464
|
|
- ) {
|
|
465
|
|
- ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
466
|
|
- "upload-progress: get_tracking_id found args: %s",p);
|
|
467
|
|
- i = 1;
|
|
468
|
|
- break;
|
|
469
|
|
- }
|
|
470
|
|
- p++;
|
|
471
|
|
- } while (len > 0);
|
|
|
410
|
+ return get_tracking_id_internal(r, &upcf->header, "get_tracking_id", false);
|
|
|
411
|
+}
|
|
472
|
412
|
|
|
473
|
|
- if (i) {
|
|
474
|
|
- start_p = p += upcf->header_mul.len + 1;
|
|
475
|
|
- while (p < args.data + args.len) {
|
|
476
|
|
- if (*(++p) == '&') {
|
|
477
|
|
- break;
|
|
478
|
|
- }
|
|
479
|
|
- }
|
|
|
413
|
+static ngx_str_t*
|
|
|
414
|
+get_tracking_ids_mul(ngx_http_request_t *r)
|
|
|
415
|
+{
|
|
|
416
|
+ ngx_http_uploadprogress_conf_t *upcf;
|
|
480
|
417
|
|
|
481
|
|
- ret = ngx_calloc(sizeof(ngx_str_t), r->connection->log);
|
|
482
|
|
- ret->data = start_p;
|
|
483
|
|
- ret->len = p - start_p;
|
|
484
|
|
- ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
485
|
|
- "upload-progress: get_tracking_id found args: %V",ret);
|
|
486
|
|
- return ret;
|
|
487
|
|
- }
|
|
488
|
|
- }
|
|
|
418
|
+ upcf = ngx_http_get_module_loc_conf(r, ngx_http_uploadprogress_module);
|
|
489
|
419
|
|
|
490
|
|
- ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
491
|
|
- "upload-progress: get_tracking_id no id found");
|
|
492
|
|
- return NULL;
|
|
|
420
|
+ return get_tracking_id_internal(r, &upcf->header_mul, "get_tracking_ids_mul", true);
|
|
493
|
421
|
}
|
|
494
|
422
|
|
|
495
|
423
|
static ngx_http_uploadprogress_node_t *
|