+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
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;
+}
+
////////////////////////////////////////////////////////////////////////
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");