error, errtxt, error, errtxt);
if (error == HTTP_STATUS_UNAUTHORIZED)
- htsbuf_qprintf(&hc->hc_reply, "<P><A HREF=\"/\">Default Login</A></P>");
+ htsbuf_qprintf(&hc->hc_reply, "<P><A HREF=\"%s/\">Default Login</A></P>",
+ tvheadend_webroot ? tvheadend_webroot : "");
htsbuf_qprintf(&hc->hc_reply, "</BODY></HTML>\r\n");
*/
void
http_redirect(http_connection_t *hc, const char *location,
- http_arg_list_t *req_args)
+ http_arg_list_t *req_args, int external)
{
const char *loc = location;
htsbuf_queue_flush(&hc->hc_reply);
htsbuf_queue_t hq;
int first = 1;
htsbuf_queue_init(&hq, 0);
+ if (!external && tvheadend_webroot && location[0] == '/')
+ htsbuf_append(&hq, tvheadend_webroot, strlen(tvheadend_webroot));
htsbuf_append(&hq, location, strlen(location));
htsbuf_append(&hq, "?", 1);
TAILQ_FOREACH(ra, req_args, link) {
}
loc = htsbuf_to_string(&hq);
htsbuf_queue_flush(&hq);
+ } else if (!external && tvheadend_webroot && location[0] == '/') {
+ loc = malloc(strlen(location) + strlen(tvheadend_webroot) + 1);
+ strcpy((char *)loc, tvheadend_webroot);
+ strcat((char *)loc, location);
}
htsbuf_qprintf(&hc->hc_reply,
void http_output_content(http_connection_t *hc, const char *content);
void http_redirect(http_connection_t *hc, const char *location,
- struct http_arg_list *req_args);
+ struct http_arg_list *req_args, int external);
void http_send_header(http_connection_t *hc, int rc, const char *content,
int64_t contentlen, const char *encoding,
if(de == NULL) {
pthread_mutex_unlock(&global_lock);
- http_redirect(hc, "/simple.html", &hc->hc_req_args);
+ http_redirect(hc, "/simple.html", &hc->hc_req_args, 0);
return 0;
}
page_root(http_connection_t *hc, const char *remain, void *opaque)
{
if(is_client_simple(hc)) {
- http_redirect(hc, "simple.html", &hc->hc_req_args);
+ http_redirect(hc, "simple.html", &hc->hc_req_args, 0);
} else {
- http_redirect(hc, "extjs.html", &hc->hc_req_args);
+ http_redirect(hc, "extjs.html", &hc->hc_req_args, 0);
}
return 0;
}
page_root2(http_connection_t *hc, const char *remain, void *opaque)
{
if (!tvheadend_webroot) return 1;
- char *tmp = malloc(strlen(tvheadend_webroot) + 2);
- sprintf(tmp, "%s/", tvheadend_webroot);
- http_redirect(hc, tmp, &hc->hc_req_args);
- free(tmp);
+ http_redirect(hc, "/", &hc->hc_req_args, 0);
return 0;
}
if (hc->hc_access != NULL &&
hc->hc_access->aa_username != NULL &&
hc->hc_access->aa_username != '\0') {
- http_redirect(hc, "/", &hc->hc_req_args);
+ http_redirect(hc, "/", &hc->hc_req_args, 0);
return 0;
} else {
return HTTP_STATUS_UNAUTHORIZED;
hc->hc_access->aa_username == NULL ||
hc->hc_access->aa_username == '\0') {
redirect:
- http_redirect(hc, "/", &hc->hc_req_args);
+ http_redirect(hc, "/", &hc->hc_req_args, 0);
return 0;
} else {
const char *s = http_arg_get(&hc->hc_args, "Cookie");
static int
favicon(http_connection_t *hc, const char *remain, void *opaque)
{
- http_redirect(hc, "static/htslogo.png", NULL);
+ http_redirect(hc, "static/htslogo.png", NULL, 0);
return 0;
}