commit 3f15ab9a508ef1c2c4588c48ae6914f375d23994
parent 0db51a5aa5bbb1e6829ef11d6efd75427cb80143
Author: Christian Grothoff <christian@grothoff.org>
Date: Sat, 27 Jun 2026 22:12:36 +0200
fix #9424
Diffstat:
1 file changed, 49 insertions(+), 7 deletions(-)
diff --git a/src/auditor/taler-auditor-httpd.c b/src/auditor/taler-auditor-httpd.c
@@ -1098,13 +1098,55 @@ handle_mhd_request (void *cls,
not_found:
if (url_match)
{
- /* FIXME: return list of allowed methods... - #9424 */
- GNUNET_break (0);
- return TALER_MHD_reply_with_error (
- connection,
- MHD_HTTP_METHOD_NOT_ALLOWED,
- TALER_EC_AUDITOR_GENERIC_METHOD_NOT_ALLOWED,
- "This method is currently disabled.");
+ /* The URL exists, but not for the requested HTTP method: respond with
+ 405 Method Not Allowed and an 'Allow' header listing the methods that
+ are supported for this URL (#9424). */
+ char allow[128] = "OPTIONS";
+ size_t aoff = strlen ("OPTIONS");
+ struct MHD_Response *resp;
+ enum MHD_Result ret;
+
+ GNUNET_break_op (0);
+ /* OPTIONS is always supported (handled above); additionally list every
+ method registered for this URL. */
+ for (unsigned int i = 0; NULL != handlers[i].url; i++)
+ {
+ const struct TAH_RequestHandler *rh = &handlers[i];
+
+ if (NULL == rh->method)
+ continue;
+ if ( (0 != strcmp (url,
+ rh->url)) &&
+ ! ( (0 == strncmp (url,
+ rh->url,
+ strlen (rh->url))) &&
+ ('/' == url[strlen (rh->url)]) ) )
+ continue;
+ GNUNET_assert (aoff + strlen (rh->method) + 3 < sizeof (allow));
+ memcpy (&allow[aoff],
+ ", ",
+ 2);
+ aoff += 2;
+ memcpy (&allow[aoff],
+ rh->method,
+ strlen (rh->method));
+ aoff += strlen (rh->method);
+ allow[aoff] = '\0';
+ }
+ resp = MHD_create_response_from_buffer (0,
+ NULL,
+ MHD_RESPMEM_PERSISTENT);
+ TALER_MHD_add_global_headers (resp,
+ false);
+ GNUNET_break (MHD_YES ==
+ MHD_add_response_header (resp,
+ MHD_HTTP_HEADER_ALLOW,
+ allow));
+ ret = MHD_queue_response (connection,
+ MHD_HTTP_METHOD_NOT_ALLOWED,
+ resp);
+ MHD_destroy_response (resp);
+ return ret;
}
#define NOT_FOUND \