* Send an HTTP REDIRECT
*/
void
-http_redirect(http_connection_t *hc, const char *location)
+http_redirect(http_connection_t *hc, const char *location,
+ http_arg_list_t *req_args)
{
+ const char *loc = location;
htsbuf_queue_flush(&hc->hc_reply);
+ if (req_args) {
+ http_arg_t *ra;
+ htsbuf_queue_t hq;
+ int first = 1;
+ htsbuf_queue_init(&hq, 0);
+ htsbuf_append(&hq, location, strlen(location));
+ htsbuf_append(&hq, "?", 1);
+ TAILQ_FOREACH(ra, req_args, link) {
+ if (!first)
+ htsbuf_append(&hq, "&", 1);
+ first = 0;
+ htsbuf_append_and_escape_url(&hq, ra->key);
+ htsbuf_append(&hq, "=", 1);
+ htsbuf_append_and_escape_url(&hq, ra->val);
+ }
+ loc = htsbuf_to_string(&hq);
+ htsbuf_queue_flush(&hq);
+ }
+
htsbuf_qprintf(&hc->hc_reply,
"<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n"
"<HTML><HEAD>\r\n"
"</HEAD><BODY>\r\n"
"Please follow <a href=\"%s\">%s</a>\r\n"
"</BODY></HTML>\r\n",
- location, location);
+ loc, loc);
- http_send_reply(hc, HTTP_STATUS_FOUND, "text/html", NULL, location, 0);
+ http_send_reply(hc, HTTP_STATUS_FOUND, "text/html", NULL, loc, 0);
+ if (loc != location)
+ free((void *)loc);
}
/**
page_root(http_connection_t *hc, const char *remain, void *opaque)
{
if(is_client_simple(hc)) {
- http_redirect(hc, "simple.html");
+ http_redirect(hc, "simple.html", &hc->hc_req_args);
} else {
- http_redirect(hc, "extjs.html");
+ http_redirect(hc, "extjs.html", &hc->hc_req_args);
}
return 0;
}
if (!tvheadend_webroot) return 1;
char *tmp = malloc(strlen(tvheadend_webroot) + 2);
sprintf(tmp, "%s/", tvheadend_webroot);
- http_redirect(hc, tmp);
+ http_redirect(hc, tmp, &hc->hc_req_args);
free(tmp);
return 0;
}
htsbuf_qprintf(hq, "#EXTM3U\n");
htsbuf_qprintf(hq, "#EXTINF:-1,%s\n", channel_get_name(channel));
- htsbuf_qprintf(hq, "http://%s%s?ticket=%s", host, buf,
+ htsbuf_qprintf(hq, "http://%s%s?ticket=%s", host, buf,
access_ticket_create(buf));
#if ENABLE_LIBAV
char buf[255];
channel_tag_mapping_t *ctm;
const char *host;
+ muxer_container_type_t mc;
hq = &hc->hc_reply;
host = http_arg_get(&hc->hc_args, "Host");
+ mc = muxer_container_txt2type(http_arg_get(&hc->hc_req_args, "mux"));
+ if(mc == MC_UNKNOWN)
+ mc = dvr_config_find_by_name_default("")->dvr_mc;
+
htsbuf_qprintf(hq, "#EXTM3U\n");
LIST_FOREACH(ctm, &tag->ct_ctms, ctm_tag_link) {
snprintf(buf, sizeof(buf), "/stream/channelid/%d", channel_get_id(ctm->ctm_channel));
htsbuf_qprintf(hq, "#EXTINF:-1,%s\n", channel_get_name(ctm->ctm_channel));
- htsbuf_qprintf(hq, "http://%s%s?ticket=%s\n", host, buf,
+ htsbuf_qprintf(hq, "http://%s%s?ticket=%s", host, buf,
access_ticket_create(buf));
+ htsbuf_qprintf(hq, "&mux=%s\n", muxer_container_type2txt(mc));
}
http_output_content(hc, "audio/x-mpegurl");
char buf[255];
channel_tag_t *ct;
const char *host;
+ muxer_container_type_t mc;
hq = &hc->hc_reply;
host = http_arg_get(&hc->hc_args, "Host");
+ mc = muxer_container_txt2type(http_arg_get(&hc->hc_req_args, "mux"));
+ if(mc == MC_UNKNOWN)
+ mc = dvr_config_find_by_name_default("")->dvr_mc;
+
htsbuf_qprintf(hq, "#EXTM3U\n");
TAILQ_FOREACH(ct, &channel_tags, ct_link) {
if(!ct->ct_enabled || ct->ct_internal)
snprintf(buf, sizeof(buf), "/playlist/tagid/%d", ct->ct_identifier);
htsbuf_qprintf(hq, "#EXTINF:-1,%s\n", ct->ct_name);
- htsbuf_qprintf(hq, "http://%s%s?ticket=%s\n", host, buf,
+ htsbuf_qprintf(hq, "http://%s%s?ticket=%s", host, buf,
access_ticket_create(buf));
+ htsbuf_qprintf(hq, "&mux=%s\n", muxer_container_type2txt(mc));
}
http_output_content(hc, "audio/x-mpegurl");
channel_t **chlist;
const char *host;
int idx = 0, count = 0;
+ muxer_container_type_t mc;
hq = &hc->hc_reply;
host = http_arg_get(&hc->hc_args, "Host");
+ mc = muxer_container_txt2type(http_arg_get(&hc->hc_req_args, "mux"));
+ if(mc == MC_UNKNOWN)
+ mc = dvr_config_find_by_name_default("")->dvr_mc;
+
CHANNEL_FOREACH(ch)
count++;
snprintf(buf, sizeof(buf), "/stream/channelid/%d", channel_get_id(ch));
htsbuf_qprintf(hq, "#EXTINF:-1,%s\n", channel_get_name(ch));
- htsbuf_qprintf(hq, "http://%s%s?ticket=%s\n", host, buf,
+ htsbuf_qprintf(hq, "http://%s%s?ticket=%s", host, buf,
access_ticket_create(buf));
+ htsbuf_qprintf(hq, "&mux=%s\n", muxer_container_type2txt(mc));
}
free(chlist);
htsbuf_qprintf(hq, "#EXT-X-PROGRAM-DATE-TIME:%s\n", buf);
snprintf(buf, sizeof(buf), "/dvrfile/%d", de->de_id);
- htsbuf_qprintf(hq, "http://%s%s?ticket=%s\n", host, buf,
+ htsbuf_qprintf(hq, "http://%s%s?ticket=%s\n", host, buf,
access_ticket_create(buf));
}
channel_tag_t *tag = NULL;
if(!remain) {
- http_redirect(hc, "/playlist/channels");
+ http_redirect(hc, "/playlist/channels", &hc->hc_req_args);
return HTTP_STATUS_FOUND;
}
static int
favicon(http_connection_t *hc, const char *remain, void *opaque)
{
- http_redirect(hc, "static/htslogo.png");
+ http_redirect(hc, "static/htslogo.png", NULL);
return 0;
}