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

https: make HTTP/2 ALPN flag an input/output parameter

This enables forcing HTTP/1 (for proxies).
parent 2c1bb0b7
......@@ -39,7 +39,7 @@ struct vlc_https_connecting
vlc_tls_creds_t *creds;
const char *host;
unsigned port;
bool http2;
bool *http2;
vlc_sem_t done;
};
......@@ -71,12 +71,12 @@ static void *vlc_https_connect_thread(void *data)
char *proxy = vlc_https_proxy_find(c->host, c->port);
if (proxy != NULL)
{
tls = vlc_https_connect_proxy(c->creds, c->host, c->port, &c->http2,
tls = vlc_https_connect_proxy(c->creds, c->host, c->port, c->http2,
proxy);
free(proxy);
}
else
tls = vlc_https_connect(c->creds, c->host, c->port, &c->http2);
tls = vlc_https_connect(c->creds, c->host, c->port, c->http2);
vlc_sem_post(&c->done);
return tls;
}
......@@ -92,6 +92,7 @@ static vlc_tls_t *vlc_https_connect_i11e(vlc_tls_creds_t *creds,
c.creds = creds;
c.host = host;
c.port = port;
c.http2 = http_two;
vlc_sem_init(&c.done, 0);
if (vlc_clone(&th, vlc_https_connect_thread, &c,
......@@ -108,8 +109,6 @@ static vlc_tls_t *vlc_https_connect_i11e(vlc_tls_creds_t *creds,
if (res == VLC_THREAD_CANCELED)
res = NULL;
if (res != NULL)
*http_two = c.http2;
return res;
}
......@@ -229,7 +228,7 @@ static struct vlc_http_msg *vlc_https_request(struct vlc_http_mgr *mgr,
if (resp != NULL)
return resp; /* existing connection reused */
bool http2;
bool http2 = true;
vlc_tls_t *tls = vlc_https_connect_i11e(mgr->creds, host, port, &http2);
if (tls == NULL)
return NULL;
......
......@@ -136,7 +136,7 @@ vlc_tls_t *vlc_https_connect(vlc_tls_creds_t *creds, const char *name,
char *alp;
vlc_tls_t *tls = vlc_tls_ClientSessionCreateFD(creds, fd, name, "https",
alpn, &alp);
alpn + !*two, &alp);
if (tls == NULL)
{
net_Close(fd);
......
......@@ -168,8 +168,8 @@ vlc_tls_t *vlc_https_connect_proxy(vlc_tls_creds_t *creds,
session->close = vlc_http_tls_close_ignore;
vlc_http_msg_destroy(resp); /* <- session is destroyed here */
session = vlc_tls_ClientSessionCreateFD(creds, fd, hostname, "https", alpn,
&alp);
session = vlc_tls_ClientSessionCreateFD(creds, fd, hostname, "https",
alpn + !*two, &alp);
#endif
if (session == NULL)
{
......
......@@ -129,7 +129,7 @@ int main(void)
{
char *url;
unsigned port;
bool two;
bool two = false;
/* Test bad URLs */
vlc_https_connect_proxy(NULL, "www.example.com", 0, &two,
......
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