more precise logging

This commit is contained in:
Christian Grothoff 2020-02-26 23:43:32 +01:00
parent c520b0b86f
commit 502c9a0fc3
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC

View File

@ -358,6 +358,7 @@ proceed_with_handler (const struct TEH_RequestHandler *rh,
if (rh->nargs > 0) if (rh->nargs > 0)
{ {
unsigned int i; unsigned int i;
const char *fin;
/* make a copy of 'url' because 'strtok()' will modify */ /* make a copy of 'url' because 'strtok()' will modify */
memcpy (d, memcpy (d,
@ -372,13 +373,24 @@ proceed_with_handler (const struct TEH_RequestHandler *rh,
that there is no excess data in 'd' afterwards */ that there is no excess data in 'd' afterwards */
if ( (i != rh->nargs) || if ( (i != rh->nargs) ||
(NULL == args[i - 1]) || (NULL == args[i - 1]) ||
(NULL != strtok (NULL, "/")) ) (NULL != (fin = strtok (NULL, "/"))) )
{ {
char emsg[128 + 512];
GNUNET_snprintf (emsg,
sizeof (emsg),
"Got %u/%u segments for %s request ('%s')",
(NULL == args[i - 1])
? i - 1
: i + ((NULL != fin) ? 1 : 0),
rh->nargs,
rh->url,
url);
GNUNET_break_op (0); GNUNET_break_op (0);
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_NOT_FOUND, MHD_HTTP_NOT_FOUND,
TALER_EC_WRONG_NUMBER_OF_SEGMENTS, TALER_EC_WRONG_NUMBER_OF_SEGMENTS,
"Number of segments does not match"); emsg);
} }
} }
@ -471,7 +483,7 @@ handle_mhd_request (void *cls,
}, },
/* Return key material and fundamental properties for this exchange */ /* Return key material and fundamental properties for this exchange */
{ {
.url = "/keys", .url = "keys",
.method = MHD_HTTP_METHOD_GET, .method = MHD_HTTP_METHOD_GET,
.handler.get = &TEH_KS_handler_keys, .handler.get = &TEH_KS_handler_keys,
}, },
@ -590,10 +602,15 @@ handle_mhd_request (void *cls,
if (NULL != ecls->rh) if (NULL != ecls->rh)
{ {
int ret; int ret;
const char *start;
if ('\0' == url[0])
/* strange, should start with '/', treat as just "/" */
url = "/";
start = strchr (url + 1, '/');
ret = proceed_with_handler (ecls->rh, ret = proceed_with_handler (ecls->rh,
connection, connection,
url, start,
inner_cls, inner_cls,
upload_data, upload_data,
upload_data_size); upload_data_size);
@ -619,7 +636,7 @@ handle_mhd_request (void *cls,
rest = strchr (tok, '/'); rest = strchr (tok, '/');
if (NULL == rest) if (NULL == rest)
{ {
tok_size = 0; tok_size = strlen (tok);
} }
else else
{ {