From c9f90924a9a11e8c83a1492efd234bca74d2aef4 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Wed, 2 Apr 2014 02:10:35 +0900 Subject: [PATCH] Add flags parameter to nghttp2_on_header_callback --- examples/libevent-client.c | 1 + examples/libevent-server.c | 1 + lib/includes/nghttp2/nghttp2.h | 16 ++++++++++------ lib/nghttp2_session.c | 1 + src/HttpServer.cc | 3 ++- src/app_helper.cc | 4 +++- src/app_helper.h | 1 + src/h2load_http2_session.cc | 1 + src/nghttp.cc | 3 ++- src/shrpx_http2_session.cc | 1 + src/shrpx_http2_upstream.cc | 3 ++- tests/nghttp2_session_test.c | 4 +++- 12 files changed, 28 insertions(+), 11 deletions(-) diff --git a/examples/libevent-client.c b/examples/libevent-client.c index aad4cf38..5194c4fe 100644 --- a/examples/libevent-client.c +++ b/examples/libevent-client.c @@ -216,6 +216,7 @@ static int on_header_callback(nghttp2_session *session, const nghttp2_frame *frame, const uint8_t *name, size_t namelen, const uint8_t *value, size_t valuelen, + uint8_t flags, void *user_data) { http2_session_data *session_data = (http2_session_data*)user_data; diff --git a/examples/libevent-server.c b/examples/libevent-server.c index a99262f1..13609462 100644 --- a/examples/libevent-server.c +++ b/examples/libevent-server.c @@ -400,6 +400,7 @@ static int on_header_callback(nghttp2_session *session, const nghttp2_frame *frame, const uint8_t *name, size_t namelen, const uint8_t *value, size_t valuelen, + uint8_t flags, void *user_data) { http2_stream_data *stream_data; diff --git a/lib/includes/nghttp2/nghttp2.h b/lib/includes/nghttp2/nghttp2.h index 05ee18bb..943fb2b4 100644 --- a/lib/includes/nghttp2/nghttp2.h +++ b/lib/includes/nghttp2/nghttp2.h @@ -1338,12 +1338,15 @@ typedef int (*nghttp2_on_begin_headers_callback) * @functypedef * * Callback function invoked when a header name/value pair is received - * for the |frame|. When this callback is invoked, ``frame->hd.type`` - * is either :enum:`NGHTTP2_HEADERS` or :enum:`NGHTTP2_PUSH_PROMISE`. - * After all header name/value pairs are processed with this callback, - * and no error has been detected, - * :type:`nghttp2_on_frame_recv_callback` will be invoked. If there - * is an error in decompression, + * for the |frame|. The |name| of length |namelen| is header name. + * The |value| of length |valuelen| is header value. The |flags| is + * bitwise OR of one or more of :type:`nghttp2_nv_flag`. + * + * When this callback is invoked, ``frame->hd.type`` is either + * :enum:`NGHTTP2_HEADERS` or :enum:`NGHTTP2_PUSH_PROMISE`. After all + * header name/value pairs are processed with this callback, and no + * error has been detected, :type:`nghttp2_on_frame_recv_callback` + * will be invoked. If there is an error in decompression, * :type:`nghttp2_on_frame_recv_callback` for the |frame| will not be * invoked. * @@ -1393,6 +1396,7 @@ typedef int (*nghttp2_on_header_callback) const nghttp2_frame *frame, const uint8_t *name, size_t namelen, const uint8_t *value, size_t valuelen, + uint8_t flags, void *user_data); /** diff --git a/lib/nghttp2_session.c b/lib/nghttp2_session.c index 2bf1e4d8..a4082388 100644 --- a/lib/nghttp2_session.c +++ b/lib/nghttp2_session.c @@ -2420,6 +2420,7 @@ static int session_call_on_header(nghttp2_session *session, rv = session->callbacks.on_header_callback(session, frame, nv->name, nv->namelen, nv->value, nv->valuelen, + nv->flags, session->user_data); if(rv == NGHTTP2_ERR_PAUSE || rv == NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE) { diff --git a/src/HttpServer.cc b/src/HttpServer.cc index 6cee9448..0e5475f5 100644 --- a/src/HttpServer.cc +++ b/src/HttpServer.cc @@ -1094,13 +1094,14 @@ int on_header_callback(nghttp2_session *session, const nghttp2_frame *frame, const uint8_t *name, size_t namelen, const uint8_t *value, size_t valuelen, + uint8_t flags, void *user_data) { auto hd = static_cast(user_data); if(hd->get_config()->verbose) { print_session_id(hd->session_id()); verbose_on_header_callback(session, frame, name, namelen, value, valuelen, - user_data); + flags, user_data); } if(frame->hd.type != NGHTTP2_HEADERS || frame->headers.cat != NGHTTP2_HCAT_REQUEST) { diff --git a/src/app_helper.cc b/src/app_helper.cc index e29e37f6..3298298e 100644 --- a/src/app_helper.cc +++ b/src/app_helper.cc @@ -469,6 +469,7 @@ int verbose_on_header_callback(nghttp2_session *session, const nghttp2_frame *frame, const uint8_t *name, size_t namelen, const uint8_t *value, size_t valuelen, + uint8_t flags, void *user_data) { nghttp2_nv nv = { @@ -476,7 +477,8 @@ int verbose_on_header_callback(nghttp2_session *session, static_cast(namelen), static_cast(valuelen) }; print_timer(); - fprintf(outfile, " (stream_id=%d) ", frame->hd.stream_id); + fprintf(outfile, " (stream_id=%d, noind=%d) ", frame->hd.stream_id, + (flags & NGHTTP2_NV_FLAG_NO_INDEX) != 0); print_nv(&nv, 1, false /* no indent */); return 0; } diff --git a/src/app_helper.h b/src/app_helper.h index 9738f836..de9b7ffb 100644 --- a/src/app_helper.h +++ b/src/app_helper.h @@ -43,6 +43,7 @@ int verbose_on_header_callback(nghttp2_session *session, const nghttp2_frame *frame, const uint8_t *name, size_t namelen, const uint8_t *value, size_t valuelen, + uint8_t flags, void *user_data); int verbose_on_frame_recv_callback diff --git a/src/h2load_http2_session.cc b/src/h2load_http2_session.cc index c5e2107f..1a0db3ca 100644 --- a/src/h2load_http2_session.cc +++ b/src/h2load_http2_session.cc @@ -59,6 +59,7 @@ int on_header_callback(nghttp2_session *session, const nghttp2_frame *frame, const uint8_t *name, size_t namelen, const uint8_t *value, size_t valuelen, + uint8_t flags, void *user_data) { auto client = static_cast(user_data); diff --git a/src/nghttp.cc b/src/nghttp.cc index d27c0b4d..8cc23d7b 100644 --- a/src/nghttp.cc +++ b/src/nghttp.cc @@ -1210,11 +1210,12 @@ int on_header_callback(nghttp2_session *session, const nghttp2_frame *frame, const uint8_t *name, size_t namelen, const uint8_t *value, size_t valuelen, + uint8_t flags, void *user_data) { if(config.verbose) { verbose_on_header_callback(session, frame, name, namelen, value, valuelen, - user_data); + flags, user_data); } switch(frame->hd.type) { case NGHTTP2_HEADERS: { diff --git a/src/shrpx_http2_session.cc b/src/shrpx_http2_session.cc index 30791478..48e8e869 100644 --- a/src/shrpx_http2_session.cc +++ b/src/shrpx_http2_session.cc @@ -788,6 +788,7 @@ int on_header_callback(nghttp2_session *session, const nghttp2_frame *frame, const uint8_t *name, size_t namelen, const uint8_t *value, size_t valuelen, + uint8_t flags, void *user_data) { if(frame->hd.type != NGHTTP2_HEADERS || diff --git a/src/shrpx_http2_upstream.cc b/src/shrpx_http2_upstream.cc index 1b0ae510..0ea93b29 100644 --- a/src/shrpx_http2_upstream.cc +++ b/src/shrpx_http2_upstream.cc @@ -179,11 +179,12 @@ int on_header_callback(nghttp2_session *session, const nghttp2_frame *frame, const uint8_t *name, size_t namelen, const uint8_t *value, size_t valuelen, + uint8_t flags, void *user_data) { if(get_config()->upstream_frame_debug) { verbose_on_header_callback(session, frame, name, namelen, value, valuelen, - user_data); + flags, user_data); } if(frame->hd.type != NGHTTP2_HEADERS || frame->headers.cat != NGHTTP2_HCAT_REQUEST) { diff --git a/tests/nghttp2_session_test.c b/tests/nghttp2_session_test.c index 94badfc9..49c902d1 100644 --- a/tests/nghttp2_session_test.c +++ b/tests/nghttp2_session_test.c @@ -295,6 +295,7 @@ static int on_header_callback(nghttp2_session *session, const nghttp2_frame *frame, const uint8_t *name, size_t namelen, const uint8_t *value, size_t valuelen, + uint8_t flags, void *user_data) { my_user_data *ud = (my_user_data*)user_data; @@ -312,9 +313,10 @@ static int pause_on_header_callback(nghttp2_session *session, const nghttp2_frame *frame, const uint8_t *name, size_t namelen, const uint8_t *value, size_t valuelen, + uint8_t flags, void *user_data) { - on_header_callback(session, frame, name, namelen, value, valuelen, + on_header_callback(session, frame, name, namelen, value, valuelen, flags, user_data); return NGHTTP2_ERR_PAUSE; }