|
|
@@ -152,14 +152,14 @@ get_tracking_id(ngx_http_request_t * r)
|
|
152
|
152
|
ret = ngx_pcalloc(r->pool, sizeof(ngx_str_t));
|
|
153
|
153
|
ret->data = header[i].value.data;
|
|
154
|
154
|
ret->len = header[i].value.len;
|
|
155
|
|
- ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
156
|
|
- "upload-progress: get_tracking_id found header: %V", ret);
|
|
|
155
|
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
|
156
|
+ "upload-progress: get_tracking_id found header: %V", ret);
|
|
157
|
157
|
return ret;
|
|
158
|
158
|
}
|
|
159
|
159
|
}
|
|
160
|
160
|
|
|
161
|
|
- ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
162
|
|
- "upload-progress: get_tracking_id no header found");
|
|
|
161
|
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
|
162
|
+ "upload-progress: get_tracking_id no header found");
|
|
163
|
163
|
|
|
164
|
164
|
/* not found, check as a reaquest arg */
|
|
165
|
165
|
if (r->args.len) {
|
|
|
@@ -179,7 +179,7 @@ get_tracking_id(ngx_http_request_t * r)
|
|
179
|
179
|
break;
|
|
180
|
180
|
}
|
|
181
|
181
|
while(p++);
|
|
182
|
|
-
|
|
|
182
|
+
|
|
183
|
183
|
if (i) {
|
|
184
|
184
|
start_p = p += 14;
|
|
185
|
185
|
while (p < r->args.data + r->args.len) {
|
|
|
@@ -191,14 +191,14 @@ get_tracking_id(ngx_http_request_t * r)
|
|
191
|
191
|
ret = ngx_pcalloc(r->pool, sizeof(ngx_str_t));
|
|
192
|
192
|
ret->data = start_p;
|
|
193
|
193
|
ret->len = p - start_p;
|
|
194
|
|
- ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
195
|
|
- "upload-progress: get_tracking_id found args: %V",ret);
|
|
|
194
|
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
|
195
|
+ "upload-progress: get_tracking_id found args: %V",ret);
|
|
196
|
196
|
return ret;
|
|
197
|
197
|
}
|
|
198
|
198
|
}
|
|
199
|
|
-
|
|
200
|
|
- ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
201
|
|
- "upload-progress: get_tracking_id no id found");
|
|
|
199
|
+
|
|
|
200
|
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
|
201
|
+ "upload-progress: get_tracking_id no id found");
|
|
202
|
202
|
return NULL;
|
|
203
|
203
|
}
|
|
204
|
204
|
|
|
|
@@ -266,10 +266,10 @@ ngx_http_uploadprogress_content_handler(ngx_http_request_t *r)
|
|
266
|
266
|
rc = upcf->handler(r);
|
|
267
|
267
|
|
|
268
|
268
|
/* bail out if error */
|
|
269
|
|
- if (rc >= NGX_HTTP_SPECIAL_RESPONSE)
|
|
270
|
|
- return rc;
|
|
271
|
|
-
|
|
272
|
|
- /* request is OK, hijack the read_event_handler */
|
|
|
269
|
+ if (rc >= NGX_HTTP_SPECIAL_RESPONSE)
|
|
|
270
|
+ return rc;
|
|
|
271
|
+
|
|
|
272
|
+ /* request is OK, hijack the read_event_handler */
|
|
273
|
273
|
upcf->read_event_handler = r->read_event_handler;
|
|
274
|
274
|
r->read_event_handler = ngx_http_uploadprogress_event_handler;
|
|
275
|
275
|
return rc;
|
|
|
@@ -286,16 +286,16 @@ static void ngx_http_uploadprogress_event_handler(ngx_http_request_t *r)
|
|
286
|
286
|
|
|
287
|
287
|
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "upload-progress: ngx_http_uploadprogress_event_handler");
|
|
288
|
288
|
|
|
289
|
|
- c = r->connection;
|
|
290
|
|
-
|
|
|
289
|
+ c = r->connection;
|
|
|
290
|
+
|
|
291
|
291
|
/* call the original read event handler */
|
|
292
|
292
|
upcf = ngx_http_get_module_loc_conf(r, ngx_http_uploadprogress_module);
|
|
293
|
293
|
upcf->read_event_handler(r);
|
|
294
|
294
|
|
|
295
|
|
- /* check that the request/connection is still OK */
|
|
296
|
|
- if (r->headers_out.status >= NGX_HTTP_SPECIAL_RESPONSE) {
|
|
297
|
|
- return;
|
|
298
|
|
- }
|
|
|
295
|
+ /* check that the request/connection is still OK */
|
|
|
296
|
+ if (r->headers_out.status >= NGX_HTTP_SPECIAL_RESPONSE) {
|
|
|
297
|
+ return;
|
|
|
298
|
+ }
|
|
299
|
299
|
|
|
300
|
300
|
/* find node, update rest */
|
|
301
|
301
|
id = get_tracking_id(r);
|
|
|
@@ -395,11 +395,11 @@ ngx_http_reportuploads_handler(ngx_http_request_t * r)
|
|
395
|
395
|
if (up != NULL) {
|
|
396
|
396
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
397
|
397
|
"reportuploads found node: %V", id);
|
|
398
|
|
- rest = up->rest;
|
|
399
|
|
- length = up->length;
|
|
400
|
|
- done = up->done;
|
|
401
|
|
- err_status = up->err_status;
|
|
402
|
|
- found = 1;
|
|
|
398
|
+ rest = up->rest;
|
|
|
399
|
+ length = up->length;
|
|
|
400
|
+ done = up->done;
|
|
|
401
|
+ err_status = up->err_status;
|
|
|
402
|
+ found = 1;
|
|
403
|
403
|
} else {
|
|
404
|
404
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
405
|
405
|
"reportuploads not found: %V", id);
|
|
|
@@ -488,15 +488,13 @@ ngx_http_reportuploads_handler(ngx_http_request_t * r)
|
|
488
|
488
|
*/
|
|
489
|
489
|
|
|
490
|
490
|
if (!found) {
|
|
491
|
|
- size = sizeof("new Object({ 'state' : 'starting' })\r\n");
|
|
492
|
|
- } else if (err_status >= NGX_HTTP_SPECIAL_RESPONSE) {
|
|
|
491
|
+ size = sizeof("new Object({ 'state' : 'starting' })\r\n");
|
|
|
492
|
+ } else if (err_status >= NGX_HTTP_SPECIAL_RESPONSE) {
|
|
493
|
493
|
size = sizeof("new Object({ 'state' : 'error', 'status' : ") + NGX_INT_T_LEN + sizeof(" })\r\n");
|
|
494
|
|
- } else if (done) {
|
|
495
|
|
- size = sizeof("new Object({ 'state' : 'done' })\r\n");
|
|
496
|
|
- } else {
|
|
497
|
|
- size =
|
|
498
|
|
- sizeof("new Object({ 'state' : 'uploading', 'received' : ") +
|
|
499
|
|
- NGX_INT_T_LEN + sizeof(" })\r\n");
|
|
|
494
|
+ } else if (done) {
|
|
|
495
|
+ size = sizeof("new Object({ 'state' : 'done' })\r\n");
|
|
|
496
|
+ } else {
|
|
|
497
|
+ size = sizeof("new Object({ 'state' : 'uploading', 'received' : ") + NGX_INT_T_LEN + sizeof(" })\r\n");
|
|
500
|
498
|
size += sizeof(", 'size' : ") + NGX_INT_T_LEN;
|
|
501
|
499
|
}
|
|
502
|
500
|
|
|
|
@@ -509,33 +507,28 @@ ngx_http_reportuploads_handler(ngx_http_request_t * r)
|
|
509
|
507
|
out.next = NULL;
|
|
510
|
508
|
|
|
511
|
509
|
if (!found) {
|
|
512
|
|
- b->last = ngx_cpymem(b->last, "new Object({ 'state' : 'starting' })\r\n",
|
|
513
|
|
- sizeof("new Object({ 'state' : 'starting' })\r\n") -
|
|
514
|
|
- 1);
|
|
515
|
|
- ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
516
|
|
- "reportuploads returning starting");
|
|
517
|
|
- } else if (err_status >= NGX_HTTP_SPECIAL_RESPONSE) {
|
|
518
|
|
- b->last = ngx_cpymem(b->last, "new Object({ 'state' : 'error', 'status' : ",
|
|
|
510
|
+ b->last = ngx_cpymem(b->last, "new Object({ 'state' : 'starting' })\r\n",
|
|
|
511
|
+ sizeof("new Object({ 'state' : 'starting' })\r\n") - 1);
|
|
|
512
|
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "reportuploads returning starting");
|
|
|
513
|
+ } else if (err_status >= NGX_HTTP_SPECIAL_RESPONSE) {
|
|
|
514
|
+ b->last = ngx_cpymem(b->last, "new Object({ 'state' : 'error', 'status' : ",
|
|
519
|
515
|
sizeof("new Object({ 'state' : 'error', 'status' : ") - 1);
|
|
520
|
|
- b->last = ngx_sprintf(b->last, "%ui })\r\n", err_status );
|
|
521
|
|
- ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
522
|
|
- "reportuploads returning error condition: %ui", err_status);
|
|
523
|
|
- } else if (done) {
|
|
524
|
|
- b->last = ngx_cpymem(b->last, "new Object({ 'state' : 'done' })\r\n",
|
|
525
|
|
- sizeof("new Object({ 'state' : 'done' })\r\n") -
|
|
526
|
|
- 1);
|
|
527
|
|
- ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
528
|
|
- "reportuploads returning done");
|
|
529
|
|
- } else {
|
|
530
|
|
- b->last =
|
|
531
|
|
- ngx_cpymem(b->last, "new Object({ 'state' : 'uploading', 'received' : ",
|
|
532
|
|
- sizeof("new Object({ 'state' : 'uploading', 'received' : ") -
|
|
533
|
|
- 1);
|
|
534
|
|
-
|
|
535
|
|
- b->last = ngx_sprintf(b->last, "%uO, 'size' : %uO })\r\n", (length - rest), length);
|
|
536
|
|
-
|
|
537
|
|
- ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
538
|
|
- "reportuploads returning %uO / %uO",(length - rest), length );
|
|
|
516
|
+ b->last = ngx_sprintf(b->last, "%ui })\r\n", err_status );
|
|
|
517
|
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
|
518
|
+ "reportuploads returning error condition: %ui", err_status);
|
|
|
519
|
+ } else if (done) {
|
|
|
520
|
+ b->last = ngx_cpymem(b->last, "new Object({ 'state' : 'done' })\r\n",
|
|
|
521
|
+ sizeof("new Object({ 'state' : 'done' })\r\n") - 1);
|
|
|
522
|
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
|
523
|
+ "reportuploads returning done");
|
|
|
524
|
+ } else {
|
|
|
525
|
+ b->last = ngx_cpymem(b->last, "new Object({ 'state' : 'uploading', 'received' : ",
|
|
|
526
|
+ sizeof("new Object({ 'state' : 'uploading', 'received' : ") - 1);
|
|
|
527
|
+
|
|
|
528
|
+ b->last = ngx_sprintf(b->last, "%uO, 'size' : %uO })\r\n", (length - rest), length);
|
|
|
529
|
+
|
|
|
530
|
+ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
|
531
|
+ "reportuploads returning %uO / %uO",(length - rest), length );
|
|
539
|
532
|
}
|
|
540
|
533
|
|
|
541
|
534
|
|