diff options
author | Mark Wielaard <mark@klomp.org> | 2020-11-21 20:20:50 +0100 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2020-11-22 00:09:33 +0100 |
commit | 371a4f814875ff47c75a76ec57a7a9098f5ab512 (patch) | |
tree | 2045c30f44481db43b4b743325e4e17e733e6ac1 | |
parent | 73548bd3e8bf82fea9c4465628a20e3e32d5de87 (diff) | |
download | elfutils-371a4f814875ff47c75a76ec57a7a9098f5ab512.tar.gz |
debuginfod: Handle "/" and report unrecognized operations
This doesn't change any functionality, but simply shows something a little
user friendlier when accessing the server "by hand" (in a browser).
Signed-off-by: Mark Wielaard <mark@klomp.org>
-rw-r--r-- | debuginfod/ChangeLog | 5 | ||||
-rw-r--r-- | debuginfod/debuginfod.cxx | 20 |
2 files changed, 24 insertions, 1 deletions
diff --git a/debuginfod/ChangeLog b/debuginfod/ChangeLog index 34e07793..b3c81285 100644 --- a/debuginfod/ChangeLog +++ b/debuginfod/ChangeLog @@ -1,3 +1,8 @@ +2020-11-21 Mark Wielaard <mark@klomp.org> + + * debuginfod.cxx (handle_root): New function. + (handler_cb): Handle "/" and report url1 in webapi error. + 2020-11-11 Mark Wielaard <mark@klomp.org> * debuginfod-find.c (progressfn): Use clock_gettime to print Progress diff --git a/debuginfod/debuginfod.cxx b/debuginfod/debuginfod.cxx index 78e2a430..61c778b1 100644 --- a/debuginfod/debuginfod.cxx +++ b/debuginfod/debuginfod.cxx @@ -1799,6 +1799,19 @@ handle_metrics (off_t* size) return r; } +static struct MHD_Response* +handle_root (off_t* size) +{ + static string version = "debuginfod (" + string (PACKAGE_NAME) + ") " + + string (PACKAGE_VERSION); + MHD_Response* r = MHD_create_response_from_buffer (version.size (), + (void *) version.c_str (), + MHD_RESPMEM_PERSISTENT); + *size = version.size (); + MHD_add_response_header (r, "Content-Type", "text/plain"); + return r; +} + //////////////////////////////////////////////////////////////////////// @@ -1876,8 +1889,13 @@ handler_cb (void * /*cls*/, inc_metric("http_requests_total", "type", "metrics"); r = handle_metrics(& http_size); } + else if (url1 == "/") + { + inc_metric("http_requests_total", "type", "/"); + r = handle_root(& http_size); + } else - throw reportable_exception("webapi error, unrecognized /operation"); + throw reportable_exception("webapi error, unrecognized '" + url1 + "'"); if (r == 0) throw reportable_exception("internal error, missing response"); |