From 1cea5816fade21e3e29967c2f10d8c26739301c3 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Sun, 19 Oct 2014 07:36:20 +0800 Subject: [PATCH] http2 dont use incoming END_STREAM when sending headers Signed-off-by: Andy Green --- lib/hpack.c | 3 +-- lib/output.c | 4 +++- lib/private-libwebsockets.h | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/hpack.c b/lib/hpack.c index 37c4319..56f66b5 100644 --- a/lib/hpack.c +++ b/lib/hpack.c @@ -668,8 +668,7 @@ int lws_add_http2_header_status(struct libwebsocket_context *context, unsigned char status[10]; int n; - if (code >= 400) - wsi->u.http2.END_STREAM = 1; + wsi->u.http2.send_END_STREAM = !!(code >= 400); n = sprintf((char *)status, "%u", code); if (lws_add_http2_header_by_token(context, wsi, WSI_TOKEN_HTTP_COLON_STATUS, status, n, p, end)) diff --git a/lib/output.c b/lib/output.c index 91c754a..cee6149 100644 --- a/lib/output.c +++ b/lib/output.c @@ -445,6 +445,8 @@ send_raw: if (protocol == LWS_WRITE_HTTP_HEADERS) { n = LWS_HTTP2_FRAME_TYPE_HEADERS; flags = LWS_HTTP2_FLAG_END_HEADERS; + if (wsi->u.http2.send_END_STREAM) + flags |= LWS_HTTP2_FLAG_END_STREAM; } if ((protocol == LWS_WRITE_HTTP || protocol == LWS_WRITE_HTTP_FINAL) && wsi->u.http.content_length) { @@ -456,7 +458,7 @@ send_raw: } } - if ((protocol == LWS_WRITE_HTTP_FINAL || protocol == LWS_WRITE_HTTP_HEADERS) && wsi->u.http2.END_STREAM) { + if (protocol == LWS_WRITE_HTTP_FINAL && wsi->u.http2.END_STREAM) { lwsl_info("%s: setting END_STREAM\n", __func__); flags |= LWS_HTTP2_FLAG_END_STREAM; } diff --git a/lib/private-libwebsockets.h b/lib/private-libwebsockets.h index 4631bfe..4f171de 100755 --- a/lib/private-libwebsockets.h +++ b/lib/private-libwebsockets.h @@ -699,6 +699,7 @@ struct _lws_http2_related { unsigned int END_STREAM:1; unsigned int END_HEADERS:1; + unsigned int send_END_STREAM:1; /* hpack */ enum http2_hpack_state hpack; -- 2.7.4