[vlc-commits] [Git][videolan/vlc][3.0.x] 2 commits: http: fix closing HTTP 1.x connection
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Sat Sep 11 16:51:22 UTC 2021
Jean-Baptiste Kempf pushed to branch 3.0.x at VideoLAN / VLC
Commits:
6496bb30 by Rémi Denis-Courmont at 2021-09-10T16:46:06+03:00
http: fix closing HTTP 1.x connection
When the client closes the stream, then underlying HTTP 1.x
connection must be terminated in any of the following cases:
- The server uses HTTP version 1.0.
- The server specified the "close" token in the Connection header line
of the HTTP response header.
- Fewer bytes than specified in the Content-Length header line of the
HTTP response header were read.
- The response body is encoded with chunked encoding and the end of the
body has not been reached.
In the first two cases, flag `connection_close` will be set. It was
write-only before this patch.
In the third case, the `content_length` will be non-zero but not
unknown (`UINTMAX_MAX`).
The last case is already handled by the chunked encoding decoder.
Fixes #26084.
(cherry picked from commit 113e98f6665e86f10aac53dcbe50fa2689ae6659)
- - - - -
248a8e56 by Rémi Denis-Courmont at 2021-09-10T16:46:11+03:00
http: account for queue in congestion window
The code would credit the congestion window whenever the server had
consumed half of the credits. If the client read data slower than the
server sent it, it would lead to arbitrarily large queues.
To avoid this, only credit the congestion window when the client has
read half the data.
Fixes #26082.
(cherry picked from commit f831ed899c4d2d3af15ad8ff706cae3f6c98fb2a)
- - - - -
2 changed files:
- modules/access/http/h1conn.c
- modules/access/http/h2conn.c
Changes:
=====================================
modules/access/http/h1conn.c
=====================================
@@ -274,7 +274,16 @@ static void vlc_h1_stream_close(struct vlc_http_stream *stream, bool abort)
assert(conn->active);
+ if (conn->connection_close)
+ /* Server requested closing the connection after this stream. */
+ abort = true;
+
+ if (conn->content_length > 0 && conn->content_length != UINTMAX_MAX)
+ /* Client left some data to be read, so pipelining is impossible. */
+ abort = true;
+
if (abort)
+ /* Shut the underlying connection down and prevent reuse. */
vlc_h1_stream_fatal(conn);
conn->active = false;
=====================================
modules/access/http/h2conn.c
=====================================
@@ -176,7 +176,6 @@ static int vlc_h2_stream_data(void *ctx, struct vlc_h2_frame *f)
free(f);
return vlc_h2_stream_fatal(s, VLC_H2_FLOW_CONTROL_ERROR);
}
- s->recv_cwnd -= len;
*(s->recv_tailp) = f;
s->recv_tailp = &f->next;
@@ -302,6 +301,12 @@ static block_t *vlc_h2_stream_read(struct vlc_http_stream *stream)
s->recv_tailp = &s->recv_head;
}
+ size_t len;
+ uint8_t *buf = vlc_h2_frame_data_get(f, &len);
+
+ assert(s->recv_cwnd >= len);
+ s->recv_cwnd -= len;
+
/* Credit the receive window if missing credit exceeds 50%. */
uint_fast32_t credit = VLC_H2_INIT_WINDOW - s->recv_cwnd;
if (credit >= (VLC_H2_INIT_WINDOW / 2)
@@ -318,9 +323,6 @@ static block_t *vlc_h2_stream_read(struct vlc_http_stream *stream)
return vlc_http_error;
}
- size_t len;
- uint8_t *buf = vlc_h2_frame_data_get(f, &len);
-
assert(block->i_buffer >= len);
assert(block->p_buffer <= buf);
assert(block->p_buffer + block->i_buffer >= buf + len);
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8625e53a91027fd1e2179d2dcc78cc28d17c50df...248a8e567aaa6e1d7051cdccac45d79281246e5c
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8625e53a91027fd1e2179d2dcc78cc28d17c50df...248a8e567aaa6e1d7051cdccac45d79281246e5c
You're receiving this email because of your account on code.videolan.org.
More information about the vlc-commits
mailing list