From 401d6951da55e61a35b3af449d8692a371b2d43a Mon Sep 17 00:00:00 2001 From: Andy Green Date: Tue, 5 May 2020 12:17:27 +0100 Subject: [PATCH] h2: client: do not apply host header if h2 negotiated by alpn If client negotiated over alpn, it will have done SNI. Some peers like youtube.com reject with 400 if you sent a host: as well. --- lib/roles/h2/http2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/roles/h2/http2.c b/lib/roles/h2/http2.c index 34008b37e..3377fb1a7 100644 --- a/lib/roles/h2/http2.c +++ b/lib/roles/h2/http2.c @@ -1414,6 +1414,7 @@ lws_h2_parse_end_of_frame(struct lws *wsi) /* pass on the initial headers to SID 1 */ h2n->swsi->http.ah = wsi->http.ah; h2n->swsi->client_mux_substream = 1; + h2n->swsi->client_h2_alpn = 1; #if defined(LWS_WITH_CLIENT) h2n->swsi->flags = wsi->flags; #endif @@ -2382,7 +2383,8 @@ lws_h2_client_handshake(struct lws *wsi) &p, end)) goto fail_length; - if (lws_add_http_header_by_token(wsi, WSI_TOKEN_HOST, + if (!wsi->client_h2_alpn && + lws_add_http_header_by_token(wsi, WSI_TOKEN_HOST, (unsigned char *)lws_hdr_simple_ptr(wsi, _WSI_TOKEN_CLIENT_HOST), lws_hdr_total_length(wsi, _WSI_TOKEN_CLIENT_HOST),