From ffb49e26123b2b4eab09770755c063fa99612770 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Tue, 23 Mar 2021 07:14:26 +0000 Subject: [PATCH] http: post: defer body pending end until no more buffered out --- lib/roles/h2/http2.c | 2 +- lib/roles/http/client/client-http.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/roles/h2/http2.c b/lib/roles/h2/http2.c index cac0278ad..02b8d6a1b 100644 --- a/lib/roles/h2/http2.c +++ b/lib/roles/h2/http2.c @@ -2538,7 +2538,7 @@ lws_h2_client_handshake(struct lws *wsi) /* below is not needed in spec, indeed it destroys the long poll * feature, but required by nghttp2 */ if ((wsi->flags & LCCSCF_H2_QUIRK_NGHTTP2_END_STREAM) && - !(wsi->client_http_body_pending)) + !(wsi->client_http_body_pending || lws_has_buffered_out(wsi))) m |= LWS_WRITE_H2_STREAM_END; #endif diff --git a/lib/roles/http/client/client-http.c b/lib/roles/http/client/client-http.c index dc599fbcf..1561aa7d6 100644 --- a/lib/roles/http/client/client-http.c +++ b/lib/roles/http/client/client-http.c @@ -286,7 +286,7 @@ hs2: break; } - if (wsi->client_http_body_pending) { + if (wsi->client_http_body_pending || lws_has_buffered_out(wsi)) { lwsl_debug("body pending\n"); lwsi_set_state(wsi, LRS_ISSUE_HTTP_BODY); lws_set_timeout(wsi, @@ -332,7 +332,7 @@ hs2: break; } #endif - if (wsi->client_http_body_pending) { + if (wsi->client_http_body_pending || lws_has_buffered_out(wsi)) { //lws_set_timeout(wsi, // PENDING_TIMEOUT_CLIENT_ISSUE_PAYLOAD, // context->timeout_secs); @@ -1216,7 +1216,7 @@ lws_generate_client_handshake(struct lws *wsi, char *pkt) p += lws_snprintf(p, lws_ptr_diff_size_t(end, p), "\x0d\x0a"); - if (wsi->client_http_body_pending) + if (wsi->client_http_body_pending || lws_has_buffered_out(wsi)) lws_callback_on_writable(wsi); lws_metrics_caliper_bind(wsi->cal_conn, wsi->a.context->mt_http_txn);