[nginx] HTTP/2: add debug logging of pseudo-headers and cookies.
Valentin Bartenev
vbart at nginx.com
Tue May 30 16:30:58 UTC 2017
details: http://hg.nginx.org/nginx/rev/ab6ef3037840
branches:
changeset: 7016:ab6ef3037840
user: Piotr Sikora <piotrsikora at google.com>
date: Tue May 30 17:42:27 2017 +0300
description:
HTTP/2: add debug logging of pseudo-headers and cookies.
Signed-off-by: Piotr Sikora <piotrsikora at google.com>
diffstat:
src/http/v2/ngx_http_v2.c | 62 ++++++++++++++++++++++++++--------------------
1 files changed, 35 insertions(+), 27 deletions(-)
diffs (82 lines):
diff -r dfed742c0183 -r ab6ef3037840 src/http/v2/ngx_http_v2.c
--- a/src/http/v2/ngx_http_v2.c Tue May 30 19:29:45 2017 +0300
+++ b/src/http/v2/ngx_http_v2.c Tue May 30 17:42:27 2017 +0300
@@ -1568,6 +1568,10 @@ ngx_http_v2_state_process_header(ngx_htt
rc = ngx_http_v2_pseudo_header(r, header);
if (rc == NGX_OK) {
+ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "http2 pseudo-header: \":%V: %V\"",
+ &header->name, &header->value);
+
return ngx_http_v2_state_header_complete(h2c, pos, end);
}
@@ -1609,36 +1613,40 @@ ngx_http_v2_state_process_header(ngx_htt
NGX_HTTP_V2_INTERNAL_ERROR);
}
- return ngx_http_v2_state_header_complete(h2c, pos, end);
- }
-
- h = ngx_list_push(&r->headers_in.headers);
- if (h == NULL) {
- return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_INTERNAL_ERROR);
- }
-
- h->key.len = header->name.len;
- h->key.data = header->name.data;
-
- /* TODO Optimization: precalculate hash and handler for indexed headers. */
- h->hash = ngx_hash_key(h->key.data, h->key.len);
-
- h->value.len = header->value.len;
- h->value.data = header->value.data;
-
- h->lowcase_key = h->key.data;
-
- cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
-
- hh = ngx_hash_find(&cmcf->headers_in_hash, h->hash,
- h->lowcase_key, h->key.len);
-
- if (hh && hh->handler(r, h, hh->offset) != NGX_OK) {
- goto error;
+ } else {
+ h = ngx_list_push(&r->headers_in.headers);
+ if (h == NULL) {
+ return ngx_http_v2_connection_error(h2c,
+ NGX_HTTP_V2_INTERNAL_ERROR);
+ }
+
+ h->key.len = header->name.len;
+ h->key.data = header->name.data;
+
+ /*
+ * TODO Optimization: precalculate hash
+ * and handler for indexed headers.
+ */
+ h->hash = ngx_hash_key(h->key.data, h->key.len);
+
+ h->value.len = header->value.len;
+ h->value.data = header->value.data;
+
+ h->lowcase_key = h->key.data;
+
+ cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
+
+ hh = ngx_hash_find(&cmcf->headers_in_hash, h->hash,
+ h->lowcase_key, h->key.len);
+
+ if (hh && hh->handler(r, h, hh->offset) != NGX_OK) {
+ goto error;
+ }
}
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
- "http2 http header: \"%V: %V\"", &h->key, &h->value);
+ "http2 http header: \"%V: %V\"",
+ &header->name, &header->value);
return ngx_http_v2_state_header_complete(h2c, pos, end);
More information about the nginx-devel
mailing list