Преглед на файлове

Restore functionality of upload-progress for HTTP2

The upload-progress module was only getting notified of the first
block of uploaded data, because r->read_event_handler was being
reset by ngx_http_v2_read_request_body() and
ngx_http_v2_process_request_body()

The patch detects that situation, updates module_ctx to call the
new function, then reinserts itself as the read_event_handler so
we continue to be notified about uploaded data.

Introduced in nginx/nginx@67d160bf25

Sponsored-by:	ScaleEngine Inc.
pull/57/head
Allan Jude преди 3 години
родител
ревизия
594f1233c3
променени са 1 файла, в които са добавени 10 реда и са изтрити 0 реда
  1. 10
    0
      ngx_http_uploadprogress_module.c

+ 10
- 0
ngx_http_uploadprogress_module.c Целия файл

@@ -489,6 +489,16 @@ static void ngx_http_uploadprogress_event_handler(ngx_http_request_t *r)
489 489
     module_ctx = ngx_http_get_module_ctx(r, ngx_http_uploadprogress_module);
490 490
     if (module_ctx != NULL ) {
491 491
         module_ctx->read_event_handler(r);
492
+        /*
493
+         * Both ngx_http_v2_read_request_body() and
494
+         * ngx_http_v2_process_request_body() modify read_event_handler,
495
+         * we respect the change, but re-interpose our function so we still get
496
+         * future events, otherwise we miss all upload progress.
497
+         */
498
+        if (r->read_event_handler != ngx_http_uploadprogress_event_handler) {
499
+            module_ctx->read_event_handler = r->read_event_handler;
500
+            r->read_event_handler = ngx_http_uploadprogress_event_handler;
501
+        }
492 502
     }
493 503
 
494 504
     /* at this stage, r is not anymore safe to use */

Loading…
Отказ
Запис