This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 1328c5613e33dafcc9f48e67db08047087d96b15 Author: Jun Zhao <[email protected]> AuthorDate: Wed Nov 18 07:14:58 2026 +0800 Commit: Jun Zhao <[email protected]> CommitDate: Thu Nov 19 12:42:05 2026 +0000 avformat/tests/http_nobody: cover clean EOF and libcurl HEAD Use MSG_NOSIGNAL in send_all(). Add two close-delimited replies without Content-Length: before the http.c fix they returned EIO with the UINT64_MAX diagnostic, now they yield clean EOF (and still deliver the 3-byte body). get_lie keeps its EIO so declared-length truncation stays covered. Unfinished chunked replies (short body, missing 0 chunk, or truncated trailer with default or disabled persistence) stay EIO, and complete 0-terminated messages still deliver their body. Add libcurl cases in their own group, FATE target and ref file, gated on CONFIG_LIBCURL_PROTOCOL: plain, gzip-encoded, whitespace-padded and zero-length HEAD, plus lowercase "head" carrying a body. Set both no_proxy and NO_PROXY so inherited proxy bypass lists cannot override the loopback check. Signed-off-by: Jun Zhao <[email protected]> --- libavformat/Makefile | 3 +- libavformat/tests/http_nobody.c | 99 ++++++++++++++++++++++++++++++++++++---- tests/fate/libavformat.mak | 4 ++ tests/ref/fate/http-curl-head | 6 +++ tests/ref/fate/http-head-no-body | 11 +++++ 5 files changed, 112 insertions(+), 11 deletions(-) diff --git a/libavformat/Makefile b/libavformat/Makefile index 0df1f0843a..0da209b17e 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -792,9 +792,10 @@ FIFO-MUXER-TESTPROGS-$(CONFIG_NETWORK) += fifo_muxer TESTPROGS-$(CONFIG_FIFO_MUXER) += $(FIFO-MUXER-TESTPROGS-yes) TESTPROGS-$(CONFIG_FFRTMPCRYPT_PROTOCOL) += rtmpdh TESTPROGS-$(CONFIG_HTTP_PROTOCOL) += http httpcookie -# http_nobody covers both the http and httpproxy read paths. +# http_nobody covers the http, httpproxy and libcurl read paths. HTTP_NOBODY_TESTPROG-$(CONFIG_HTTP_PROTOCOL) = http_nobody HTTP_NOBODY_TESTPROG-$(CONFIG_HTTPPROXY_PROTOCOL) = http_nobody +HTTP_NOBODY_TESTPROG-$(CONFIG_LIBCURL_PROTOCOL) = http_nobody TESTPROGS += $(HTTP_NOBODY_TESTPROG-yes) TESTPROGS-$(CONFIG_NETWORK) += noproxy TESTPROGS-$(CONFIG_SRTP) += srtp diff --git a/libavformat/tests/http_nobody.c b/libavformat/tests/http_nobody.c index 4bcc9d8bbc..13d5f94fa5 100644 --- a/libavformat/tests/http_nobody.c +++ b/libavformat/tests/http_nobody.c @@ -1,9 +1,10 @@ /* * Copyright (c) 2026 Jun Zhao * - * Regression tests for HTTP / httpproxy premature-end handling (issue #26071). - * Expected output lives in tests/ref/fate/http-head-no-body and - * tests/ref/fate/httpproxy-tunnel-eof. + * Regression tests for HTTP / httpproxy premature-end handling (issue #26071), + * unknown-length clean EOF and libcurl HEAD. + * Expected output lives in tests/ref/fate/http-head-no-body, + * tests/ref/fate/httpproxy-tunnel-eof and tests/ref/fate/http-curl-head. * * This file is part of FFmpeg. * @@ -68,6 +69,52 @@ static const char head_reply[] = static const char lie_reply[] = GET_HEADER; static const char connect_reply[] = "HTTP/1.1 200 OK\r\nconnection: close\r\n\r\n"; +/* Unknown-length replies ending in a clean close: no Content-Length, so + * filesize stays UINT64_MAX. These must yield EOF, not a premature-end EIO. */ +static const char close_reply[] = + "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n"; +static const char close_body_reply[] = + "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\nABC"; + +/* Chunked replies. Accept-Ranges makes the stream seekable, which is the + * path that used to report a clean close of an unfinished chunk as EOF. + * A finished message still ends at its terminating 0 chunk. */ +static const char chunk_short_reply[] = + "HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n" + "Accept-Ranges: bytes\r\nConnection: close\r\n\r\n" + "5\r\nABC"; +static const char chunk_open_reply[] = + "HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n" + "Accept-Ranges: bytes\r\nConnection: close\r\n\r\n" + "3\r\nABC\r\n"; +static const char chunk_trailer_reply[] = + "HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n" + "Accept-Ranges: bytes\r\nConnection: close\r\n\r\n" + "3\r\nABC\r\n0\r\n"; +static const char chunk_done_reply[] = + "HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n" + "Accept-Ranges: bytes\r\nConnection: close\r\n\r\n" + "3\r\nABC\r\n0\r\n\r\n"; + +/* HEAD reply for the libcurl protocol: a body-less response with a declared + * resource size, used to verify -method HEAD is no longer dropped. */ +static const char curl_head_reply[] = + "HTTP/1.1 200 OK\r\nContent-Length: 1150\r\nConnection: close\r\n\r\n"; +static const char curl_head_gzip_reply[] = + "HTTP/1.1 200 OK\r\nContent-Length: 1150\r\n" + "Content-Encoding: gzip\r\nConnection: close\r\n\r\n"; +static const char curl_head_pad_reply[] = + "HTTP/1.1 200 OK\r\n" + "Content-Length: 001150\r\n" + "Connection: close\r\n\r\n"; +static const char curl_head_zero_reply[] = + "HTTP/1.1 200 OK\r\nContent-Length: 0\r\nConnection: close\r\n\r\n"; +/* Lowercase "head" is a distinct method token, so it must carry its body. + * Omit Content-Length so AVSEEK_SIZE stays ENOSYS across libcurl versions + * that populate CURLINFO_CONTENT_LENGTH_DOWNLOAD_T at different points. */ +static const char curl_lc_head_reply[] = + "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\nABC"; + /* CONNECT 200 header and initial tunnel payload sent together in an attempt * to exercise forwarding of bytes buffered during header parsing, while still * verifying full payload delivery across short transfers. */ @@ -75,7 +122,7 @@ static const char coalesced_reply[] = "HTTP/1.1 200 OK\r\n\r\n" MARK; static char body_reply[sizeof(GET_HEADER) - 1 + BODY_SIZE]; -enum { GROUP_HTTP = 1, GROUP_PROXY = 2 }; +enum { GROUP_HTTP = 1, GROUP_PROXY = 2, GROUP_LIBCURL = 4 }; enum { PRINT_NONE, PRINT_ENDS, PRINT_TEXT }; typedef struct TestCase { @@ -86,6 +133,7 @@ typedef struct TestCase { const char *reply; int reply_len; int payload_print; + int no_persist; } TestCase; typedef struct TestServer { @@ -111,7 +159,7 @@ static void set_timeouts(int fd) static int send_all(int fd, const char *buf, int len) { for (int sent = 0; sent < len;) { - int r = send(fd, buf + sent, len - sent, 0); + int r = send(fd, buf + sent, len - sent, MSG_NOSIGNAL); if (r < 0 && ff_neterrno() == AVERROR(EINTR)) continue; if (r <= 0) @@ -231,14 +279,18 @@ static void run_case(const TestCase *tc) } snprintf(url, sizeof(url), tc->url_fmt, srv.port); - if (tc->group == GROUP_HTTP) + if (tc->group != GROUP_PROXY) av_dict_set(&opts, "http_proxy", "", 0); + if (tc->group == GROUP_LIBCURL) + av_dict_set(&opts, "prefer_libcurl", "1", 0); av_dict_set_int(&opts, "rw_timeout", TIMEOUT_US, 0); if (tc->method) av_dict_set(&opts, "method", tc->method, 0); + if (tc->no_persist) + av_dict_set(&opts, "multiple_requests", "0", 0); open_ret = ffurl_open_whitelist(&uc, url, AVIO_FLAG_READ, &int_cb, &opts, - "http,httpproxy,tcp", NULL, NULL); + "http,httpproxy,tcp,libcurl", NULL, NULL); av_dict_free(&opts); if (open_ret >= 0) { size_ret = ffurl_seek(uc, 0, AVSEEK_SIZE); @@ -267,18 +319,45 @@ static const TestCase cases[] = { NULL, body_reply, sizeof(body_reply), PRINT_ENDS }, { "get_lie", GROUP_HTTP, "http://127.0.0.1:%d/x", NULL, lie_reply, sizeof(lie_reply) - 1, PRINT_NONE }, + { "get_close", GROUP_HTTP, "http://127.0.0.1:%d/x", + NULL, close_reply, sizeof(close_reply) - 1, PRINT_NONE }, + { "get_close_body", GROUP_HTTP, "http://127.0.0.1:%d/x", + NULL, close_body_reply, sizeof(close_body_reply) - 1, PRINT_TEXT }, + { "chunk_short", GROUP_HTTP, "http://127.0.0.1:%d/x", + NULL, chunk_short_reply, sizeof(chunk_short_reply) - 1, PRINT_NONE }, + { "chunk_open", GROUP_HTTP, "http://127.0.0.1:%d/x", + NULL, chunk_open_reply, sizeof(chunk_open_reply) - 1, PRINT_NONE }, + { "chunk_trailer", GROUP_HTTP, "http://127.0.0.1:%d/x", + NULL, chunk_trailer_reply, sizeof(chunk_trailer_reply) - 1, PRINT_NONE }, + { "chunk_trailer_mr0", GROUP_HTTP, "http://127.0.0.1:%d/x", + NULL, chunk_trailer_reply, sizeof(chunk_trailer_reply) - 1, PRINT_NONE, 1 }, + { "chunk_done", GROUP_HTTP, "http://127.0.0.1:%d/x", + NULL, chunk_done_reply, sizeof(chunk_done_reply) - 1, PRINT_TEXT }, + { "chunk_done_mr0", GROUP_HTTP, "http://127.0.0.1:%d/x", + NULL, chunk_done_reply, sizeof(chunk_done_reply) - 1, PRINT_TEXT, 1 }, { "proxy_close", GROUP_PROXY, "httpproxy://127.0.0.1:%d/example.com:443", NULL, connect_reply, sizeof(connect_reply) - 1, PRINT_NONE }, { "proxy_residue", GROUP_PROXY, "httpproxy://127.0.0.1:%d/example.com:443", NULL, coalesced_reply, sizeof(coalesced_reply) - 1, PRINT_TEXT }, + { "curl_head", GROUP_LIBCURL, "http://127.0.0.1:%d/x", + "HEAD", curl_head_reply, sizeof(curl_head_reply) - 1, PRINT_NONE }, + { "curl_head_gzip", GROUP_LIBCURL, "http://127.0.0.1:%d/x", + "HEAD", curl_head_gzip_reply, sizeof(curl_head_gzip_reply) - 1, PRINT_NONE }, + { "curl_head_pad", GROUP_LIBCURL, "http://127.0.0.1:%d/x", + "HEAD", curl_head_pad_reply, sizeof(curl_head_pad_reply) - 1, PRINT_NONE }, + { "curl_head_zero", GROUP_LIBCURL, "http://127.0.0.1:%d/x", + "HEAD", curl_head_zero_reply, sizeof(curl_head_zero_reply) - 1, PRINT_NONE }, + { "curl_lc_head", GROUP_LIBCURL, "http://127.0.0.1:%d/x", + "head", curl_lc_head_reply, sizeof(curl_lc_head_reply) - 1, PRINT_TEXT }, }; int main(int argc, char **argv) { const char *group = argc > 1 ? argv[1] : "all"; - int mask = !strcmp(group, "all") ? (GROUP_HTTP | GROUP_PROXY) : - !strcmp(group, "http") ? GROUP_HTTP : - !strcmp(group, "proxy") ? GROUP_PROXY : 0; + int mask = !strcmp(group, "all") ? (GROUP_HTTP | GROUP_PROXY) : + !strcmp(group, "http") ? GROUP_HTTP : + !strcmp(group, "proxy") ? GROUP_PROXY : + !strcmp(group, "libcurl") ? GROUP_LIBCURL : 0; if (!mask) { fprintf(stderr, "Unknown test group: %s\n", group); diff --git a/tests/fate/libavformat.mak b/tests/fate/libavformat.mak index 36d812c24d..30436cb52b 100644 --- a/tests/fate/libavformat.mak +++ b/tests/fate/libavformat.mak @@ -68,6 +68,7 @@ fate-noproxy: CMD = run libavformat/tests/noproxy$(EXESUF) # Self-contained loopback test; it needs no samples and no external network. FATE_HTTP_NOBODY-$(CONFIG_HTTP_PROTOCOL) += fate-http-head-no-body FATE_HTTP_NOBODY-$(CONFIG_HTTPPROXY_PROTOCOL) += fate-httpproxy-tunnel-eof +FATE_HTTP_NOBODY-$(CONFIG_LIBCURL_PROTOCOL) += fate-http-curl-head FATE_HTTP_NOBODY_RUN-$(HAVE_LOOPBACK) += $(FATE_HTTP_NOBODY-yes) FATE_LIBAVFORMAT-$(HAVE_PTHREADS) += $(FATE_HTTP_NOBODY_RUN-yes) @@ -77,6 +78,9 @@ fate-http-head-no-body: CMD = run libavformat/tests/http_nobody$(EXESUF) http fate-httpproxy-tunnel-eof: libavformat/tests/http_nobody$(EXESUF) fate-httpproxy-tunnel-eof: CMD = run libavformat/tests/http_nobody$(EXESUF) proxy +fate-http-curl-head: libavformat/tests/http_nobody$(EXESUF) +fate-http-curl-head: CMD = no_proxy=127.0.0.1,localhost NO_PROXY=127.0.0.1,localhost run libavformat/tests/http_nobody$(EXESUF) libcurl + FATE_LIBAVFORMAT-$(CONFIG_FFRTMPCRYPT_PROTOCOL) += fate-rtmpdh fate-rtmpdh: libavformat/tests/rtmpdh$(EXESUF) fate-rtmpdh: CMD = run libavformat/tests/rtmpdh$(EXESUF) diff --git a/tests/ref/fate/http-curl-head b/tests/ref/fate/http-curl-head new file mode 100644 index 0000000000..a651298944 --- /dev/null +++ b/tests/ref/fate/http-curl-head @@ -0,0 +1,6 @@ +curl_head: open=0 size=1150 read=EOF server_failed=0 +curl_head_gzip: open=0 size=1150 read=EOF server_failed=0 +curl_head_pad: open=0 size=1150 read=EOF server_failed=0 +curl_head_zero: open=0 size=0 read=EOF server_failed=0 +curl_lc_head: open=0 size=ENOSYS read=3 server_failed=0 +residue: ABC diff --git a/tests/ref/fate/http-head-no-body b/tests/ref/fate/http-head-no-body index 08adc9862e..61b7330558 100644 --- a/tests/ref/fate/http-head-no-body +++ b/tests/ref/fate/http-head-no-body @@ -2,3 +2,14 @@ head: open=0 size=1150 read=EOF server_failed=0 get_body: open=0 size=1150 read=1150 server_failed=0 body ends: X X get_lie: open=0 size=1150 read=EIO server_failed=0 +get_close: open=0 size=ENOSYS read=EOF server_failed=0 +get_close_body: open=0 size=ENOSYS read=3 server_failed=0 +residue: ABC +chunk_short: open=0 size=ENOSYS read=EIO server_failed=0 +chunk_open: open=0 size=ENOSYS read=EIO server_failed=0 +chunk_trailer: open=0 size=ENOSYS read=EIO server_failed=0 +chunk_trailer_mr0: open=0 size=ENOSYS read=EIO server_failed=0 +chunk_done: open=0 size=ENOSYS read=3 server_failed=0 +residue: ABC +chunk_done_mr0: open=0 size=ENOSYS read=3 server_failed=0 +residue: ABC -- To stop receiving notification emails like this one, please contact [email protected]. _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
