[Libwebsockets] Missing LWS_CALLBACK_HTTP_BODY_COMPLETION when using H2 https

Andy Green andy at warmcat.com
Thu Nov 18 09:12:57 CET 2021



On 11/18/21 07:58, Søren Holm wrote:
> Neither 4.3-stable with or without the additional patch works.

What does it mean, to not "work"?  Are we still talking about the 
complaint from curl side + lack of BODY_COMPLETION?

Current v4.3-stable + the patch:

diff --git a/lib/roles/h2/ops-h2.c b/lib/roles/h2/ops-h2.c
index a791081176..989cb5b95e 100644
--- a/lib/roles/h2/ops-h2.c
+++ b/lib/roles/h2/ops-h2.c
@@ -837,6 +837,9 @@ lws_h2_bind_for_post_before_action(struct lws *wsi)

                 if (hit->protocol)
                         name = hit->protocol;
+               else
+                       if (hit->origin_protocol == LWSMPRO_FILE)
+                               return 0;

                 pp = lws_vhost_name_to_protocol(wsi->a.vhost, name);
                 if (!pp) {


Following your reproduction instructions

client:  curl -v  --insecure --data-raw "blah blah" 
https://localhost:7681/form1

*   Trying 127.0.0.1:7681...
* Connected to localhost (127.0.0.1) port 7681 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*  CAfile: /etc/pki/tls/certs/ca-bundle.crt
*  CApath: none
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN, server accepted to use h2
* Server certificate:
*  subject: C=GB; ST=Erewhon; L=All around; O=libwebsockets-test; 
CN=localhost; emailAddress=none at invalid.org
*  start date: Mar 20 04:16:07 2018 GMT
*  expire date: Feb 24 04:16:07 2118 GMT
*  issuer: C=GB; ST=Erewhon; L=All around; O=libwebsockets-test; 
CN=localhost; emailAddress=none at invalid.org
*  SSL certificate verify result: self signed certificate (18), 
continuing anyway.
* Using HTTP2, server supports multiplexing
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after 
upgrade: len=0
* Using Stream ID: 1 (easy handle 0x556aa8e51dc0)
 > POST /form1 HTTP/2
 > Host: localhost:7681
 > user-agent: curl/7.79.1
 > accept: */*
 > content-length: 9
 > content-type: application/x-www-form-urlencoded
 >
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* old SSL session ID is stale, removing
* Connection state changed (MAX_CONCURRENT_STREAMS == 24)!
* We are completely uploaded and fine
< HTTP/2 301
< content-security-policy: default-src 'none'; img-src 'self' data: ; 
script-src 'self'; font-src 'self'; style-src 'self'; connect-src 'self' 
ws: wss:; frame-ancestors 'none'; base-uri 'none';form-action 'self';
< x-content-type-options: nosniff
< x-xss-protection: 1; mode=block
< x-frame-options: deny
< referrer-policy: no-referrer
< location: after-form1.html
< content-type: text/html
< content-length: 0
<
* Connection #0 to host localhost left intact

Corresponding server-form-post

[2021/11/18 08:07:14:5498] U: LWS minimal http server POST | visit 
http://localhost:7681
[2021/11/18 08:07:14:5499] N: lws_create_context: LWS: 
4.3.0-v4.3.0-66-gbc83a57207, NET CLI SRV H1 H2 WS MQTT SS-JSON-POL 
SSPROX ConMon ASYNC_DNS IPV6-on
[2021/11/18 08:07:14:5500] N: __lws_lc_tag:  ++ [1158361|wsi|0|pipe] (1)
[2021/11/18 08:07:14:5500] N: __lws_lc_tag:  ++ [1158361|vh|0|netlink] (1)
[2021/11/18 08:07:14:5520] N: __lws_lc_tag:  ++ 
[1158361|vh|1|system||-1] (2)
[2021/11/18 08:07:14:5521] N: __lws_lc_tag:  ++ 
[1158361|wsisrv|0|adopted] (1)
[2021/11/18 08:07:14:5522] N: __lws_lc_tag:  ++ 
[1158361|vh|2|default||7681] (3)
[2021/11/18 08:07:14:5522] N:  Vhost 'default' using TLS mode
[2021/11/18 08:07:14:5574] N: [1158361|vh|2|default||7681]: 
lws_socket_bind: source ads 0.0.0.0
[2021/11/18 08:07:14:5574] N: __lws_lc_tag:  ++ 
[1158361|wsi|1|listen|default||7681] (2)
[2021/11/18 08:07:14:5575] N: [1158361|vh|2|default||7681]: 
lws_socket_bind: source ads ::
[2021/11/18 08:07:14:5575] N: __lws_lc_tag:  ++ 
[1158361|wsi|2|listen|default||7681] (3)
[2021/11/18 08:07:29:3961] N: __lws_lc_tag:  ++ 
[1158361|wsisrv|1|adopted] (2)
[2021/11/18 08:07:29:3961] N: lws_gate_accepts: on = 0
[2021/11/18 08:07:29:4052] N: lws_gate_accepts: on = 0
[2021/11/18 08:07:29:4053] N: __lws_lc_tag:  ++ 
[1158361|mux|0|h2_sid1_(1158361|wsisrv|1)] (1)
[2021/11/18 08:07:29:4054] U: LWS_CALLBACK_HTTP_BODY_COMPLETION  <<<===
[2021/11/18 08:07:29:4054] U: text1: undefined
[2021/11/18 08:07:29:4054] U: send: undefined
[2021/11/18 08:07:29:4054] N: __lws_lc_untag:  -- 
[1158361|mux|0|h2_sid1_(1158361|wsisrv|1)] (0) 133μs
[2021/11/18 08:07:29:4058] N: lws_gate_accepts: on = 0
[2021/11/18 08:07:29:4059] N: __lws_lc_untag:  -- 
[1158361|wsisrv|1|adopted] (1) 9.767ms


> 
> torsdag den 18. november 2021 08.36.09 CET skrev Andy Green:
>> On 11/18/21 07:27, Søren Holm wrote:
>>> I'm pretty sure. I rebuild my distro package with the patch. I'll have
>>> another go later inserting a printf or something just to make sure that
>>> the modified code is actually running.
>>>
>>> Btw. I applied i to 4.3.0 - I assume that was your intension.
>>
>> I checked it against main.  But I think that code was broken for a while.
>>
>> When there's a release, there's a -stable branch created with fixes,
>> currently v4.3-stable is 64 patches ahead of 4.3.0 tag.  There's no
>> value ignoring those 64 fixes and going with 4.3.0.
>>
>> -Andy
> 


More information about the Libwebsockets mailing list