comparison src/http/v3/ngx_http_v3_filter_module.c @ 8614:8fc9c7f2c533 quic

HTTP/3: added debug logging of response fields. Because of QPACK compression it's hard to see what fields are actually sent by the server.
author Sergey Kandaurov <pluknet@nginx.com>
date Mon, 13 Sep 2021 16:25:37 +0300
parents 051968b73c59
children 6a383020d61e
comparison
equal deleted inserted replaced
8613:051968b73c59 8614:8fc9c7f2c533
338 } 338 }
339 339
340 b->last = (u_char *) ngx_http_v3_encode_field_section_prefix(b->last, 340 b->last = (u_char *) ngx_http_v3_encode_field_section_prefix(b->last,
341 0, 0, 0); 341 0, 0, 0);
342 342
343 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
344 "http3 output header: \":status: %03ui\"",
345 r->headers_out.status);
346
343 if (r->headers_out.status == NGX_HTTP_OK) { 347 if (r->headers_out.status == NGX_HTTP_OK) {
344 b->last = (u_char *) ngx_http_v3_encode_field_ri(b->last, 0, 348 b->last = (u_char *) ngx_http_v3_encode_field_ri(b->last, 0,
345 NGX_HTTP_V3_HEADER_STATUS_200); 349 NGX_HTTP_V3_HEADER_STATUS_200);
346 350
347 } else { 351 } else {
363 } else { 367 } else {
364 p = (u_char *) "nginx"; 368 p = (u_char *) "nginx";
365 n = sizeof("nginx") - 1; 369 n = sizeof("nginx") - 1;
366 } 370 }
367 371
372 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
373 "http3 output header: \"server: %*s\"", n, p);
374
368 b->last = (u_char *) ngx_http_v3_encode_field_lri(b->last, 0, 375 b->last = (u_char *) ngx_http_v3_encode_field_lri(b->last, 0,
369 NGX_HTTP_V3_HEADER_SERVER, 376 NGX_HTTP_V3_HEADER_SERVER,
370 p, n); 377 p, n);
371 } 378 }
372 379
373 if (r->headers_out.date == NULL) { 380 if (r->headers_out.date == NULL) {
381 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
382 "http3 output header: \"date: %V\"",
383 &ngx_cached_http_time);
384
374 b->last = (u_char *) ngx_http_v3_encode_field_lri(b->last, 0, 385 b->last = (u_char *) ngx_http_v3_encode_field_lri(b->last, 0,
375 NGX_HTTP_V3_HEADER_DATE, 386 NGX_HTTP_V3_HEADER_DATE,
376 ngx_cached_http_time.data, 387 ngx_cached_http_time.data,
377 ngx_cached_http_time.len); 388 ngx_cached_http_time.len);
378 } 389 }
401 412
402 r->headers_out.content_type.len = n; 413 r->headers_out.content_type.len = n;
403 r->headers_out.content_type.data = p - n; 414 r->headers_out.content_type.data = p - n;
404 } 415 }
405 416
417 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
418 "http3 output header: \"content-type: %V\"",
419 &r->headers_out.content_type);
420
406 b->last = (u_char *) ngx_http_v3_encode_field_lri(b->last, 0, 421 b->last = (u_char *) ngx_http_v3_encode_field_lri(b->last, 0,
407 NGX_HTTP_V3_HEADER_CONTENT_TYPE_TEXT_PLAIN, 422 NGX_HTTP_V3_HEADER_CONTENT_TYPE_TEXT_PLAIN,
408 r->headers_out.content_type.data, 423 r->headers_out.content_type.data,
409 r->headers_out.content_type.len); 424 r->headers_out.content_type.len);
410 } 425 }
411 426
412 if (r->headers_out.content_length == NULL) { 427 if (r->headers_out.content_length == NULL
428 && r->headers_out.content_length_n >= 0)
429 {
430 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
431 "http3 output header: \"content-length: %O\"",
432 r->headers_out.content_length_n);
433
413 if (r->headers_out.content_length_n > 0) { 434 if (r->headers_out.content_length_n > 0) {
414 p = ngx_sprintf(b->last, "%O", r->headers_out.content_length_n); 435 p = ngx_sprintf(b->last, "%O", r->headers_out.content_length_n);
415 n = p - b->last; 436 n = p - b->last;
416 437
417 b->last = (u_char *) ngx_http_v3_encode_field_lri(b->last, 0, 438 b->last = (u_char *) ngx_http_v3_encode_field_lri(b->last, 0,
419 NULL, n); 440 NULL, n);
420 441
421 b->last = ngx_sprintf(b->last, "%O", 442 b->last = ngx_sprintf(b->last, "%O",
422 r->headers_out.content_length_n); 443 r->headers_out.content_length_n);
423 444
424 } else if (r->headers_out.content_length_n == 0) { 445 } else {
425 b->last = (u_char *) ngx_http_v3_encode_field_ri(b->last, 0, 446 b->last = (u_char *) ngx_http_v3_encode_field_ri(b->last, 0,
426 NGX_HTTP_V3_HEADER_CONTENT_LENGTH_ZERO); 447 NGX_HTTP_V3_HEADER_CONTENT_LENGTH_ZERO);
427 } 448 }
428 } 449 }
429 450
437 return NGX_ERROR; 458 return NGX_ERROR;
438 } 459 }
439 460
440 ngx_http_time(p, r->headers_out.last_modified_time); 461 ngx_http_time(p, r->headers_out.last_modified_time);
441 462
463 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
464 "http3 output header: \"last-modified: %*s\"", n, p);
465
442 b->last = (u_char *) ngx_http_v3_encode_field_lri(b->last, 0, 466 b->last = (u_char *) ngx_http_v3_encode_field_lri(b->last, 0,
443 NGX_HTTP_V3_HEADER_LAST_MODIFIED, 467 NGX_HTTP_V3_HEADER_LAST_MODIFIED,
444 p, n); 468 p, n);
445 } 469 }
446 470
447 if (r->headers_out.location && r->headers_out.location->value.len) { 471 if (r->headers_out.location && r->headers_out.location->value.len) {
472 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
473 "http3 output header: \"location: %V\"",
474 &r->headers_out.location->value);
475
448 b->last = (u_char *) ngx_http_v3_encode_field_lri(b->last, 0, 476 b->last = (u_char *) ngx_http_v3_encode_field_lri(b->last, 0,
449 NGX_HTTP_V3_HEADER_LOCATION, 477 NGX_HTTP_V3_HEADER_LOCATION,
450 r->headers_out.location->value.data, 478 r->headers_out.location->value.data,
451 r->headers_out.location->value.len); 479 r->headers_out.location->value.len);
452 } 480 }
453 481
454 #if (NGX_HTTP_GZIP) 482 #if (NGX_HTTP_GZIP)
455 if (r->gzip_vary) { 483 if (r->gzip_vary) {
484 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0,
485 "http3 output header: \"vary: Accept-Encoding\"");
486
456 b->last = (u_char *) ngx_http_v3_encode_field_ri(b->last, 0, 487 b->last = (u_char *) ngx_http_v3_encode_field_ri(b->last, 0,
457 NGX_HTTP_V3_HEADER_VARY_ACCEPT_ENCODING); 488 NGX_HTTP_V3_HEADER_VARY_ACCEPT_ENCODING);
458 } 489 }
459 #endif 490 #endif
460 491
474 } 505 }
475 506
476 if (header[i].hash == 0) { 507 if (header[i].hash == 0) {
477 continue; 508 continue;
478 } 509 }
510
511 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
512 "http3 output header: \"%V: %V\"",
513 &header[i].key, &header[i].value);
479 514
480 b->last = (u_char *) ngx_http_v3_encode_field_l(b->last, 515 b->last = (u_char *) ngx_http_v3_encode_field_l(b->last,
481 &header[i].key, 516 &header[i].key,
482 &header[i].value); 517 &header[i].value);
483 } 518 }
1415 if (header[i].hash == 0) { 1450 if (header[i].hash == 0) {
1416 continue; 1451 continue;
1417 } 1452 }
1418 1453
1419 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 1454 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1420 "http3 trailer: \"%V: %V\"", 1455 "http3 output trailer: \"%V: %V\"",
1421 &header[i].key, &header[i].value); 1456 &header[i].key, &header[i].value);
1422 1457
1423 b->last = (u_char *) ngx_http_v3_encode_field_l(b->last, 1458 b->last = (u_char *) ngx_http_v3_encode_field_l(b->last,
1424 &header[i].key, 1459 &header[i].key,
1425 &header[i].value); 1460 &header[i].value);