aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2011-11-10 15:26:23 +0200
committerMartin Storsjö <martin@martin.st>2011-11-18 10:59:53 +0200
commit2565dbeb3e36e4f2d7970aa756c6ac40b7f46914 (patch)
treeb754274e5ece5de4575e3573c55914a5d6d4a1b9 /libavformat
parentf5c5d57b57ba74be4d8475d729675e464ed4ecb9 (diff)
downloadffmpeg-2565dbeb3e36e4f2d7970aa756c6ac40b7f46914.tar.gz
tls: Handle connection via a http proxy
Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/tls.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/libavformat/tls.c b/libavformat/tls.c
index 72c2b85016..339b799322 100644
--- a/libavformat/tls.c
+++ b/libavformat/tls.c
@@ -111,9 +111,15 @@ static int tls_open(URLContext *h, const char *uri, int flags)
char buf[200], host[200];
int numerichost = 0;
struct addrinfo hints = { 0 }, *ai = NULL;
+ const char *proxy_path;
+ int use_proxy;
ff_tls_init();
+ proxy_path = getenv("http_proxy");
+ use_proxy = (proxy_path != NULL) && !getenv("no_proxy") &&
+ av_strstart(proxy_path, "http://", NULL);
+
av_url_split(NULL, 0, NULL, 0, host, sizeof(host), &port, NULL, 0, uri);
ff_url_join(buf, sizeof(buf), "tcp", NULL, host, port, NULL);
@@ -123,6 +129,17 @@ static int tls_open(URLContext *h, const char *uri, int flags)
freeaddrinfo(ai);
}
+ if (use_proxy) {
+ char proxy_host[200], proxy_auth[200], dest[200];
+ int proxy_port;
+ av_url_split(NULL, 0, proxy_auth, sizeof(proxy_auth),
+ proxy_host, sizeof(proxy_host), &proxy_port, NULL, 0,
+ proxy_path);
+ ff_url_join(dest, sizeof(dest), NULL, NULL, host, port, NULL);
+ ff_url_join(buf, sizeof(buf), "httpproxy", proxy_auth, proxy_host,
+ proxy_port, "/%s", dest);
+ }
+
ret = ffurl_open(&c->tcp, buf, AVIO_FLAG_READ_WRITE,
&h->interrupt_callback, NULL);
if (ret)