]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
download: pass full url to the process callback
authorJaroslav Kysela <perex@perex.cz>
Thu, 19 Nov 2015 14:35:40 +0000 (15:35 +0100)
committerJaroslav Kysela <perex@perex.cz>
Thu, 19 Nov 2015 14:35:40 +0000 (15:35 +0100)
src/download.c

index b849fff112712e7e2ff8146c0454853ace4e263e..185714d80897df61ccda082e25dfad3f12776eb6 100644 (file)
@@ -96,10 +96,8 @@ static int
 download_fetch_complete(http_client_t *hc)
 {
   download_t *dn = hc->hc_aux;
-  char *last_url = NULL;
-  char host_url[512];
-  char *s, *p;
-  url_t u, u2;
+  const char *last_url = NULL;
+  url_t u;
 
   switch (hc->hc_code) {
   case HTTP_STATUS_MOVED:
@@ -115,25 +113,6 @@ download_fetch_complete(http_client_t *hc)
     if (last_url)
       last_url++;
   }
-  if ((p = http_arg_get(&hc->hc_args, "Host")) != NULL) {
-    snprintf(host_url, sizeof(host_url), "%s://%s",
-             hc->hc_ssl ? "https" : "http", p);
-  } else if (dn->url) {
-    s = strdupa(dn->url);
-    if ((p = strchr(s, '/')) != NULL) {
-      p++;
-      if (*p == '/')
-        p++;
-      if ((p = strchr(p, '/')) != NULL)
-        *p = '\0';
-    }
-    urlinit(&u2);
-    if (!urlparse(s, &u2))
-      snprintf(host_url, sizeof(host_url), "%s", s);
-    urlreset(&u2);
-  } else {
-    host_url[0] = '\0';
-  }
 
   pthread_mutex_lock(&global_lock);
 
@@ -141,7 +120,7 @@ download_fetch_complete(http_client_t *hc)
     goto out;
 
   if (hc->hc_code == HTTP_STATUS_OK && hc->hc_result == 0 && hc->hc_data_size > 0)
-    dn->process(dn->aux, last_url, host_url, hc->hc_data, hc->hc_data_size);
+    dn->process(dn->aux, last_url, hc->hc_url, hc->hc_data, hc->hc_data_size);
   else
     tvherror(dn->log, "unable to fetch data from url [%d-%d/%zd]",
              hc->hc_code, hc->hc_result, hc->hc_data_size);