diff --git a/libavformat/http.c b/libavformat/http.c
index e697578..33a303b 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -26,6 +26,7 @@
 #include "internal.h"
 #include "network.h"
 #include "os_support.h"
+#include "http.h"
 #include "httpauth.h"
 
 /* XXX: POST protocol is not completely implemented because ffmpeg uses
@@ -53,7 +54,7 @@ static int http_write(URLContext *h, uint8_t *buf, int size);
 
 
 /* return non zero if error */
-static int http_open_cnx(URLContext *h)
+int ff_http_connect(URLContext *h)
 {
     const char *path, *proxy_path;
     char hostname[1024], hoststr[1024];
@@ -138,10 +139,13 @@ static int http_open(URLContext *h, const char *uri, int flags)
     memset(&s->auth_state, 0, sizeof(s->auth_state));
     av_strlcpy(s->location, uri, URL_SIZE);
 
-    ret = http_open_cnx(h);
-    if (ret != 0)
-        av_free (s);
-    return ret;
+    if (!(flags & URL_DELAYOPEN)) {
+        ret = ff_http_connect(h);
+        if (ret != 0)
+            av_free (s);
+        return ret;
+    }
+    return 0;
 }
 static int http_getc(HTTPContext *s)
 {
@@ -425,7 +429,7 @@ static int64_t http_seek(URLContext *h, int64_t off, int whence)
     s->off = off;
 
     /* if it fails, continue on old connection */
-    if (http_open_cnx(h) < 0) {
+    if (ff_http_connect(h) < 0) {
         memcpy(s->buffer, old_buf, old_buf_size);
         s->buf_ptr = s->buffer;
         s->buf_end = s->buffer + old_buf_size;
diff --git a/libavformat/http.h b/libavformat/http.h
new file mode 100644
index 0000000..9ef421c
--- /dev/null
+++ b/libavformat/http.h
@@ -0,0 +1,33 @@
+/*
+ * HTTP definitions
+ * Copyright (c) 2002 Fabrice Bellard
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#ifndef AVFORMAT_HTTP_H
+#define AVFORMAT_HTTP_H
+
+/**
+ * Opens the connection using an initialized HTTP context.
+ *
+ * @param h URL context for this HTTP connecton
+ *
+ * @return nonzero if error, 0 on success.
+ */
+int ff_http_connect(URLContext *h);
+
+#endif
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 358959c..d40b6e0 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -29,6 +29,8 @@ typedef struct AVCodecTag {
     unsigned int tag;
 } AVCodecTag;
 
+#define URL_DELAYOPEN 4 /* follows URL_* scheme defined in avio.h */
+
 void ff_dynarray_add(intptr_t **tab_ptr, int *nb_ptr, intptr_t elem);
 
 #ifdef __GNUC__
