implement #6181
This commit is contained in:
parent
b4cfefcdb3
commit
52f370c8e4
@ -420,6 +420,45 @@ proceed_with_handler (const struct TEH_RequestHandler *rh,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle a "/seed" request.
|
||||||
|
*
|
||||||
|
* @param rh context of the handler
|
||||||
|
* @param connection the MHD connection to handle
|
||||||
|
* @param args array of additional options (must be empty for this function)
|
||||||
|
* @return MHD result code
|
||||||
|
*/
|
||||||
|
static MHD_RESULT
|
||||||
|
handler_seed (const struct TEH_RequestHandler *rh,
|
||||||
|
struct MHD_Connection *connection,
|
||||||
|
const char *const args[])
|
||||||
|
{
|
||||||
|
#define SEED_SIZE 32
|
||||||
|
char *body;
|
||||||
|
MHD_RESULT ret;
|
||||||
|
struct MHD_Response *resp;
|
||||||
|
|
||||||
|
(void) rh;
|
||||||
|
body = malloc (SEED_SIZE); /* must use malloc(), because MHD will use free() */
|
||||||
|
if (NULL == body)
|
||||||
|
return MHD_NO;
|
||||||
|
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
|
||||||
|
body,
|
||||||
|
SEED_SIZE);
|
||||||
|
resp = MHD_create_response_from_buffer (SEED_SIZE,
|
||||||
|
body,
|
||||||
|
MHD_RESPMEM_MUST_FREE);
|
||||||
|
TALER_MHD_add_global_headers (resp);
|
||||||
|
ret = MHD_queue_response (connection,
|
||||||
|
MHD_HTTP_OK,
|
||||||
|
resp);
|
||||||
|
GNUNET_break (MHD_YES == ret);
|
||||||
|
MHD_destroy_response (resp);
|
||||||
|
return ret;
|
||||||
|
#undef SEED_SIZE
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle incoming HTTP request.
|
* Handle incoming HTTP request.
|
||||||
*
|
*
|
||||||
@ -472,6 +511,11 @@ handle_mhd_request (void *cls,
|
|||||||
.method = MHD_HTTP_METHOD_GET,
|
.method = MHD_HTTP_METHOD_GET,
|
||||||
.handler.get = &TEH_handler_agpl_redirect
|
.handler.get = &TEH_handler_agpl_redirect
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.url = "seed",
|
||||||
|
.method = MHD_HTTP_METHOD_GET,
|
||||||
|
.handler.get = &handler_seed
|
||||||
|
},
|
||||||
/* Terms of service */
|
/* Terms of service */
|
||||||
{
|
{
|
||||||
.url = "terms",
|
.url = "terms",
|
||||||
@ -654,9 +698,10 @@ handle_mhd_request (void *cls,
|
|||||||
{
|
{
|
||||||
struct TEH_RequestHandler *rh = &handlers[i];
|
struct TEH_RequestHandler *rh = &handlers[i];
|
||||||
|
|
||||||
if (0 != strncmp (tok,
|
if ( (0 != strncmp (tok,
|
||||||
rh->url,
|
rh->url,
|
||||||
tok_size))
|
tok_size)) ||
|
||||||
|
(tok_size != strlen (rh->url) ) )
|
||||||
continue;
|
continue;
|
||||||
found = GNUNET_YES;
|
found = GNUNET_YES;
|
||||||
/* The URL is a match! What we now do depends on the method. */
|
/* The URL is a match! What we now do depends on the method. */
|
||||||
|
@ -205,10 +205,6 @@ run (void *cls,
|
|||||||
MHD_HTTP_PRECONDITION_FAILED,
|
MHD_HTTP_PRECONDITION_FAILED,
|
||||||
"EUR:50",
|
"EUR:50",
|
||||||
"deposit-refund-1"),
|
"deposit-refund-1"),
|
||||||
TALER_TESTING_cmd_refund ("refund-fee-too-low",
|
|
||||||
MHD_HTTP_BAD_REQUEST,
|
|
||||||
"EUR:5",
|
|
||||||
"deposit-refund-1"),
|
|
||||||
TALER_TESTING_cmd_end ()
|
TALER_TESTING_cmd_end ()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user