From 07495c20c828d9c49a8bddb723724f13958222a2 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Thu, 3 Oct 2019 07:58:24 -0700 Subject: [PATCH] h2: overflow quirk Some servers set the tx credit to the absolute max and then add to it... this is illegal (and checked for in h2spec). Add a quirk flag that works around it by reducing the initial tx credit size by a factor of 16. --- include/libwebsockets/lws-client.h | 1 + lib/roles/h2/http2.c | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/libwebsockets/lws-client.h b/include/libwebsockets/lws-client.h index 3c0393468..a5fdd485f 100644 --- a/include/libwebsockets/lws-client.h +++ b/include/libwebsockets/lws-client.h @@ -41,6 +41,7 @@ enum lws_client_connect_ssl_connection_flags { LCCSCF_ALLOW_EXPIRED = (1 << 3), LCCSCF_ALLOW_INSECURE = (1 << 4), LCCSCF_H2_QUIRK_NGHTTP2_END_STREAM = (1 << 5), + LCCSCF_H2_QUIRK_OVERFLOWS_TXCR = (1 << 6), LCCSCF_PIPELINE = (1 << 16), /**< Serialize / pipeline multiple client connections diff --git a/lib/roles/h2/http2.c b/lib/roles/h2/http2.c index b8d4f96aa..32e5b160e 100644 --- a/lib/roles/h2/http2.c +++ b/lib/roles/h2/http2.c @@ -456,10 +456,15 @@ lws_h2_settings(struct lws *wsi, struct http2_settings *settings, return 1; } +#if defined(LWS_WITH_CLIENT) #if defined(LWS_AMAZON_RTOS) || defined(LWS_AMAZON_LINUX) - if (b == 0x7fffffff) { - b = 65535; - lwsl_info("init window size 0x7fffffff\n"); + if ( +#else + if (wsi->flags & LCCSCF_H2_QUIRK_OVERFLOWS_TXCR && +#endif + b == 0x7fffffff) { + b >>= 4; + break; } #endif