[vlc-commits] http: use vlc_tls_SocketOpenTLS()
Rémi Denis-Courmont
git at videolan.org
Sat Feb 25 22:41:58 CET 2017
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Feb 25 21:44:21 2017 +0200| [1f85fe4be5c1490e328c0c308a0c73f047137834] | committer: Rémi Denis-Courmont
http: use vlc_tls_SocketOpenTLS()
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1f85fe4be5c1490e328c0c308a0c73f047137834
---
modules/access/http/Makefile.am | 2 +-
modules/access/http/connmgr.c | 20 ++++++++++++++
modules/access/http/transport.c | 58 -----------------------------------------
3 files changed, 21 insertions(+), 59 deletions(-)
diff --git a/modules/access/http/Makefile.am b/modules/access/http/Makefile.am
index d447a42..8e6f041 100644
--- a/modules/access/http/Makefile.am
+++ b/modules/access/http/Makefile.am
@@ -3,7 +3,7 @@ libhttps_plugin_la_LIBADD = libvlc_http.la
access_LTLIBRARIES += libhttps_plugin.la
libvlc_http_la_SOURCES = \
- access/http/transport.c access/http/transport.h \
+ access/http/transport.h \
access/http/message.c access/http/message.h \
access/http/resource.c access/http/resource.h \
access/http/file.c access/http/file.h \
diff --git a/modules/access/http/connmgr.c b/modules/access/http/connmgr.c
index 9bc374d..5554744 100644
--- a/modules/access/http/connmgr.c
+++ b/modules/access/http/connmgr.c
@@ -52,6 +52,26 @@ void vlc_http_dbg(void *ctx, const char *fmt, ...)
va_end(ap);
}
+vlc_tls_t *vlc_https_connect(vlc_tls_creds_t *creds, const char *name,
+ unsigned port, bool *restrict two)
+{
+ if (port == 0)
+ port = 443;
+
+ /* TLS with ALPN */
+ const char *alpn[] = { "h2", "http/1.1", NULL };
+ char *alp;
+
+ vlc_tls_t *tls = vlc_tls_SocketOpenTLS(creds, name, port, "https",
+ alpn + !*two, &alp);
+ if (tls != NULL)
+ {
+ *two = (alp != NULL) && !strcmp(alp, "h2");
+ free(alp);
+ }
+ return tls;
+}
+
static char *vlc_http_proxy_find(const char *hostname, unsigned port,
bool secure)
{
diff --git a/modules/access/http/transport.c b/modules/access/http/transport.c
deleted file mode 100644
index 2a1247a..0000000
--- a/modules/access/http/transport.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*****************************************************************************
- * transport.c: HTTP/TLS TCP transport layer
- *****************************************************************************
- * Copyright © 2015 Rémi Denis-Courmont
- *
- * This program 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.
- *
- * This program 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdlib.h>
-#include <vlc_common.h>
-#include <vlc_tls.h>
-
-#include "transport.h"
-
-vlc_tls_t *vlc_https_connect(vlc_tls_creds_t *creds, const char *name,
- unsigned port, bool *restrict two)
-{
- if (port == 0)
- port = 443;
-
- /* TODO: implement fast open. This requires merging vlc_tls_SocketOpenTCP()
- * and vlc_tls_ClientSessionCreate() though. */
- vlc_tls_t *sock = vlc_tls_SocketOpenTCP(creds->obj.parent, name, port);
- if (sock == NULL)
- return NULL;
-
- /* TLS with ALPN */
- const char *alpn[] = { "h2", "http/1.1", NULL };
- char *alp;
-
- vlc_tls_t *tls = vlc_tls_ClientSessionCreate(creds, sock, name, "https",
- alpn + !*two, &alp);
- if (tls == NULL)
- {
- vlc_tls_Close(sock);
- return NULL;
- }
-
- *two = (alp != NULL) && !strcmp(alp, "h2");
- free(alp);
- return tls;
-}
More information about the vlc-commits
mailing list