diff --git a/src/httpd.c b/src/httpd.c index 7988ae41..9405d7a4 100644 --- a/src/httpd.c +++ b/src/httpd.c @@ -262,14 +262,13 @@ httpd_fixup_uri(struct evhttp_request *req) /* --------------------------- REQUEST HELPERS ------------------------------ */ - void -httpd_redirect_to_admin(struct evhttp_request *req) +httpd_redirect_to(struct evhttp_request *req, const char *path) { struct evkeyvalq *headers; headers = evhttp_request_get_output_headers(req); - evhttp_add_header(headers, "Location", "/admin.html"); + evhttp_add_header(headers, "Location", path); httpd_send_reply(req, HTTP_MOVETEMP, "Moved", NULL, HTTPD_SEND_NO_GZIP); } @@ -451,17 +450,9 @@ serve_file(struct evhttp_request *req, const char *uri) ret = stat(path, &sb); if (ret < 0) { - if (strcmp(uri, "/") == 0) - { - httpd_redirect_to_admin(req); - return; - } - else - { - DPRINTF(E_LOG, L_HTTPD, "Could not stat() %s: %s\n", path, strerror(errno)); - httpd_send_error(req, HTTP_NOTFOUND, "Not Found"); - return; - } + DPRINTF(E_LOG, L_HTTPD, "Could not stat() %s: %s\n", path, strerror(errno)); + httpd_send_error(req, HTTP_NOTFOUND, "Not Found"); + return; } } @@ -833,14 +824,14 @@ httpd_gen_cb(struct evhttp_request *req, void *arg) if (!uri) { DPRINTF(E_WARN, L_HTTPD, "No URI in request\n"); - httpd_redirect_to_admin(req); + httpd_redirect_to(req, "/"); return; } parsed = httpd_uri_parse(uri); if (!parsed || !parsed->path) { - httpd_redirect_to_admin(req); + httpd_redirect_to(req, "/"); goto out; } diff --git a/src/httpd.h b/src/httpd.h index dc0479af..15ec4739 100644 --- a/src/httpd.h +++ b/src/httpd.h @@ -150,10 +150,10 @@ void httpd_send_error(struct evhttp_request *req, int error, const char *reason); /* - * Redirects to /admin.html + * Redirects to the given path */ void -httpd_redirect_to_admin(struct evhttp_request *req); +httpd_redirect_to(struct evhttp_request *req, const char *path); bool diff --git a/src/httpd_oauth.c b/src/httpd_oauth.c index 6c614740..25c8d6c2 100644 --- a/src/httpd_oauth.c +++ b/src/httpd_oauth.c @@ -60,7 +60,7 @@ oauth_reply_spotify(struct httpd_request *hreq) return -1; } - httpd_redirect_to_admin(hreq->req); + httpd_redirect_to(hreq->req, "/#/settings/online-services"); return 0; }