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