Commit 18752ec6 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

http: refactor proxy query helper

Adds support for insecure origin servers.
parent 84d42581
......@@ -34,27 +34,19 @@
#pragma GCC visibility push(default)
struct vlc_https_connecting
{
vlc_tls_creds_t *creds;
const char *host;
unsigned port;
bool *http2;
vlc_sem_t done;
};
static char *vlc_https_proxy_find(const char *hostname, unsigned port)
static char *vlc_http_proxy_find(const char *hostname, unsigned port,
bool secure)
{
const char *fmt;
char *url, *proxy = NULL;
int canc = vlc_savecancel();
if (strchr(hostname, ':') != NULL)
fmt = port ? "https://[%s]:%u" : "https://[%s]";
fmt = port ? "http%s://[%s]:%u" : "http%s://[%s]";
else
fmt = port ? "https://%s:%u" : "https://%s";
fmt = port ? "http%s://%s:%u" : "http%s://%s";
if (likely(asprintf(&url, fmt, hostname, port) >= 0))
if (likely(asprintf(&url, fmt, secure ? "s" : "", hostname, port) >= 0))
{
proxy = vlc_getProxyUrl(url);
free(url);
......@@ -63,12 +55,21 @@ static char *vlc_https_proxy_find(const char *hostname, unsigned port)
return proxy;
}
struct vlc_https_connecting
{
vlc_tls_creds_t *creds;
const char *host;
unsigned port;
bool *http2;
vlc_sem_t done;
};
static void *vlc_https_connect_thread(void *data)
{
struct vlc_https_connecting *c = data;
vlc_tls_t *tls;
char *proxy = vlc_https_proxy_find(c->host, c->port);
char *proxy = vlc_http_proxy_find(c->host, c->port, true);
if (proxy != NULL)
{
tls = vlc_https_connect_proxy(c->creds, c->host, c->port, c->http2,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment