Commit 9a3d58183d for ffmpeg

commit 9a3d58183dcd3c8a4bfad43520aedf341ff62d22
Author: Kacper Michajłow <kasper93@gmail.com>
Date:   Thu Oct 1 01:15:57 2026 +0200

    avformat/libcurl: take the open result from the first reply

    Decide whether the open succeeded from the first reply only, so that a
    follow-up request that the loop thread has already started cannot fail
    the open after the first reply turned out usable.

    Signed-off-by: Kacper Michajłow <kasper93@gmail.com>

diff --git a/libavformat/libcurl.c b/libavformat/libcurl.c
index 80c1f7a9fa..23d7f5f751 100644
--- a/libavformat/libcurl.c
+++ b/libavformat/libcurl.c
@@ -174,6 +174,7 @@ struct CurlContext {

     /* Probe result. Set by the loop thread, read by url_open() once probed. */
     int             probed;
+    int             probe_ok;    /* the first reply can be read */
     int             stream_ok;
     int             seekable;
     int64_t         content_size;
@@ -626,7 +627,10 @@ static size_t header_callback(char *ptr, size_t size, size_t nitems, void *userd
         c->stream_ok = 0;
         update_status_locked(c, ff_http_averror(status, AVERROR(EIO)), CURLE_OK);
     }
-    c->probed = 1;
+    if (!c->probed) {
+        c->probe_ok = c->stream_ok;
+        c->probed = 1;
+    }
     pthread_cond_broadcast(&c->cond);
     pthread_mutex_unlock(&c->mutex);

@@ -1349,7 +1353,7 @@ static int wait_for_probe(CurlContext *c)
         curl_cond_wait(c);
     }
     if (!ret) {
-        if (!c->stream_ok)
+        if (!c->probe_ok)
             ret = c->status ? c->status : AVERROR(EIO);
     }
     pthread_mutex_unlock(&c->mutex);