]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
IPTV: http - add support for URLs without full spec
authorJaroslav Kysela <perex@perex.cz>
Fri, 30 Oct 2015 08:05:58 +0000 (09:05 +0100)
committerJaroslav Kysela <perex@perex.cz>
Fri, 30 Oct 2015 08:05:58 +0000 (09:05 +0100)
src/input/mpegts/iptv/iptv_http.c

index 9e983bc6e995cb86ad01df89babc8996136aa3ae..799d0951c2631456538c57cfe719e08aa7d2f69e 100644 (file)
@@ -133,7 +133,7 @@ iptv_http_complete
   ( http_client_t *hc )
 {
   iptv_mux_t *im = hc->hc_aux;
-  char *url;
+  char *url, sbuf[512], *s, *p;
   url_t u;
   int r;
 
@@ -147,12 +147,28 @@ iptv_http_complete
       return 0;
     }
     urlinit(&u);
+    if (url[0] == '/') {
+      s = strdupa(im->mm_iptv_url_raw);
+      if ((p = strchr(s, '/')) != NULL)
+        *p = '\0';
+      if (!urlparse(s, &u))
+        goto invalid;
+      if ((s = http_arg_get(&hc->hc_args, "Host")) != NULL) {
+        snprintf(sbuf, sizeof(sbuf), "%s://%s%s",
+                 hc->hc_ssl ? "https" : "http", s, url);
+      } else if (im->mm_iptv_url_raw) {
+        snprintf(sbuf, sizeof(sbuf), "%s%s", s, url);
+      }
+      url = sbuf;
+      urlinit(&u);
+    }
     if (!urlparse(url, &u)) {
       hc->hc_keepalive = 0;
       r = http_client_simple_reconnect(hc, &u, HTTP_VERSION_1_1);
       if (r < 0)
         tvherror("iptv", "cannot reopen http client: %d'", r);
     } else {
+invalid:
       tvherror("iptv", "m3u url invalid '%s'", url);
     }
     urlreset(&u);