]> git.ipfire.org Git - thirdparty/curl.git/commit
http2: close the http2 connection when no more requests may be sent
authorLaramie Leavitt <laramie.leavitt@gmail.com>
Thu, 2 Jul 2020 23:46:22 +0000 (16:46 -0700)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 3 Jul 2020 09:16:48 +0000 (11:16 +0200)
commitef86daf4d39e99b227d42bb712000c9adfdbdf76
treeb0cabefae38803ba6e46e8ffe75378c7738266ce
parent1535363e728aa956bd64dd0325d8e38264a15468
http2: close the http2 connection when no more requests may be sent

Well-behaving HTTP2 servers send two GOAWAY messages. The first
message is a warning that indicates that the server is going to
stop accepting streams. The second one actually closes the stream.

nghttp2 reports this state (and the other state of no more stream
identifiers) via the call nghttp2_session_check_request_allowed().
In this state the client should not create more streams on the
session (tcp connection), and in curl this means that the server
has requested that the connection is closed.

It would be also be possible to put the connclose() call into the
on_http2_frame_recv() function that triggers on the GOAWAY message.

This fixes a bug seen when the client sees the following sequence of
frames:

// advisory GOAWAY
HTTP2 GOAWAY [stream-id = 0, promised-stream-id = -1]
... some additional frames

// final GOAWAY
HTTP2 GOAWAY [stream-id = 0, promised-stream-id = N ]

Before this change, curl will attempt to reuse the connection even
after the last stream, will encounter this error:

* Found bundle for host localhost: 0x5595f0a694e0 [can multiplex]
* Re-using existing connection! (#0) with host localhost
* Connected to localhost (::1) port 10443 (#0)
* Using Stream ID: 9 (easy handle 0x5595f0a72e30)
> GET /index.html?5 HTTP/2
> Host: localhost:10443
> user-agent: curl/7.68.0
> accept: */*
>
* stopped the pause stream!
* Connection #0 to host localhost left intact
curl: (16) Error in the HTTP2 framing layer

This error may posion the connection cache, causing future requests
which resolve to the same curl connection to go through the same error
path.

Closes #5643
lib/http2.c