From 8ab079ccc293f484d7fa3a247f8201bb8975366e Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Wed, 3 Aug 2016 00:13:09 +0900 Subject: [PATCH] Call error callback when invalid header field is received and ignored We have a code to call error callback when invalid header is received and it is treated as stream error. But we didn't if the incoming header is invalid, but just ignored. This generosity is required to handle public Internet connections especially when nghttp2 is used as forward proxy. --- lib/nghttp2_session.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/nghttp2_session.c b/lib/nghttp2_session.c index 8e381700..d086ea26 100644 --- a/lib/nghttp2_session.c +++ b/lib/nghttp2_session.c @@ -3604,11 +3604,24 @@ static int inflate_header_block(nghttp2_session *session, nghttp2_frame *frame, } if (rv == NGHTTP2_ERR_IGN_HTTP_HEADER) { + /* Don't overwrite rv here */ + int rv2; /* header is ignored */ DEBUGF(fprintf( stderr, "recv: HTTP ignored: type=%u, id=%d, header %.*s: %.*s\n", frame->hd.type, subject_stream->stream_id, (int)nv.name->len, nv.name->base, (int)nv.value->len, nv.value->base)); + + rv2 = session_call_error_callback( + session, + "Ignoring received invalid HTTP header field: frame type: " + "%u, stream: %d, name: [%.*s], value: [%.*s]", + frame->hd.type, frame->hd.stream_id, (int)nv.name->len, + nv.name->base, (int)nv.value->len, nv.value->base); + + if (nghttp2_is_fatal(rv2)) { + return rv2; + } } } if (rv == 0) {