From dba0f35ee1822fa63b451aff9729dc5d1253cc1f Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Wed, 27 Apr 2016 22:57:19 +0900 Subject: [PATCH] Avoid 0-length DATA if NGHTTP2_DATA_FLAG_NO_END_STREAM is set --- lib/nghttp2_session.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/nghttp2_session.c b/lib/nghttp2_session.c index 95377c53..0f7fd853 100644 --- a/lib/nghttp2_session.c +++ b/lib/nghttp2_session.c @@ -6906,6 +6906,14 @@ int nghttp2_session_pack_data(nghttp2_session *session, nghttp2_bufs *bufs, reschedule_stream(stream); + if (frame->hd.length == 0 && (data_flags & NGHTTP2_DATA_FLAG_EOF) && + (data_flags & NGHTTP2_DATA_FLAG_NO_END_STREAM)) { + /* DATA payload length is 0, and DATA frame does not bear + END_STREAM. In this case, there is no point to send 0 length + DATA frame. */ + return NGHTTP2_ERR_CANCEL; + } + return 0; }