http2 dont use incoming END_STREAM when sending headers
authorAndy Green <andy.green@linaro.org>
Sat, 18 Oct 2014 23:36:20 +0000 (07:36 +0800)
committerAndy Green <andy.green@linaro.org>
Sat, 18 Oct 2014 23:36:20 +0000 (07:36 +0800)
Signed-off-by: Andy Green <andy.green@linaro.org>
lib/hpack.c
lib/output.c
lib/private-libwebsockets.h

index 37c4319..56f66b5 100644 (file)
@@ -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))
index 91c754a..cee6149 100644 (file)
@@ -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;
                        }
index 4631bfe..4f171de 100755 (executable)
@@ -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;