PR #23415 opened by Niklas Haas (haasn) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23415 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23415.patch
Either one of these commits should fix #23222, but I think both are beneficial. >From eac467b050eae1dc7a534feb1c52df7e25331310 Mon Sep 17 00:00:00 2001 From: Niklas Haas <[email protected]> Date: Tue, 9 Jun 2026 12:35:23 +0200 Subject: [PATCH 1/2] avformat/http: infer default s->willclose based on request header If we send `Connection: close` but don't get any response Connection header back from the HTTP server, we should still assume the server will close our connection. Signed-off-by: Niklas Haas <[email protected]> --- libavformat/http.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libavformat/http.c b/libavformat/http.c index fca9f55fe6..773750d289 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -1531,6 +1531,7 @@ static int http_connect(URLContext *h, const char *path, const char *local_path, uint64_t off = s->off; const char *method; int send_expect_100 = 0; + int keep_alive = 1; /* HTTP/1.1 default */ av_bprint_init_for_buffer(&request, s->buffer, sizeof(s->buffer)); @@ -1607,8 +1608,10 @@ static int http_connect(URLContext *h, const char *path, const char *local_path, if (send_expect_100 && !has_header(s->headers, "\r\nExpect: ")) av_bprintf(&request, "Expect: 100-continue\r\n"); - if (!has_header(s->headers, "\r\nConnection: ")) - av_bprintf(&request, "Connection: %s\r\n", s->multiple_requests ? "keep-alive" : "close"); + if (!has_header(s->headers, "\r\nConnection: ")) { + keep_alive = s->multiple_requests; + av_bprintf(&request, "Connection: %s\r\n", keep_alive ? "keep-alive" : "close"); + } if (!has_header(s->headers, "\r\nHost: ")) av_bprintf(&request, "Host: %s\r\n", hoststr); @@ -1659,7 +1662,7 @@ static int http_connect(URLContext *h, const char *path, const char *local_path, s->off = 0; s->icy_data_read = 0; s->filesize = UINT64_MAX; - s->willclose = 0; + s->willclose = !keep_alive; s->end_chunked_post = 0; s->end_header = 0; #if CONFIG_ZLIB -- 2.52.0 >From 2a4413cb1afeac2dcb7e5b044a8d53beb15a5adc Mon Sep 17 00:00:00 2001 From: Niklas Haas <[email protected]> Date: Tue, 9 Jun 2026 12:37:04 +0200 Subject: [PATCH 2/2] avformat/http: accept case-insensitive Connection header value Some HTTP servers (e.g. MythTV) send an incorrect `Connection: Close` header, leading to FFmpeg assuming the connection is keep-alive, because it only checks for case-sensitive "close". Fixes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/23222 Signed-off-by: Niklas Haas <[email protected]> --- libavformat/http.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/http.c b/libavformat/http.c index 773750d289..8d5d9bec23 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -1288,7 +1288,7 @@ static int process_line(URLContext *h, char *line, int line_count, int *parsed_h } else if (!av_strcasecmp(tag, "Proxy-Authenticate")) { ff_http_auth_handle_header(&s->proxy_auth_state, tag, p); } else if (!av_strcasecmp(tag, "Connection")) { - if (!strcmp(p, "close")) + if (!av_strcasecmp(p, "close")) s->willclose = 1; } else if (!av_strcasecmp(tag, "Server")) { if (!av_strcasecmp(p, "AkamaiGHost")) { -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
