diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-05-01 19:41:14 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-05-19 01:05:57 +0200 |
commit | c7086fccd394a76b0b6a0b89217fa74efbfdfa43 (patch) | |
tree | 8e4ea1142ae8042bb8667bfe237830b84758ee19 | |
parent | 846c3640799d8ed593e4a9caa043cae7d14bc1b6 (diff) | |
download | exchange-c7086fccd394a76b0b6a0b89217fa74efbfdfa43.tar.gz exchange-c7086fccd394a76b0b6a0b89217fa74efbfdfa43.zip |
implement #6181
-rw-r--r-- | src/exchange/taler-exchange-httpd.c | 51 | ||||
-rw-r--r-- | src/testing/test_exchange_api_twisted.c | 4 |
2 files changed, 48 insertions, 7 deletions
diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c index a8e29d300..00932c0f0 100644 --- a/src/exchange/taler-exchange-httpd.c +++ b/src/exchange/taler-exchange-httpd.c | |||
@@ -421,6 +421,45 @@ proceed_with_handler (const struct TEH_RequestHandler *rh, | |||
421 | 421 | ||
422 | 422 | ||
423 | /** | 423 | /** |
424 | * Handle a "/seed" request. | ||
425 | * | ||
426 | * @param rh context of the handler | ||
427 | * @param connection the MHD connection to handle | ||
428 | * @param args array of additional options (must be empty for this function) | ||
429 | * @return MHD result code | ||
430 | */ | ||
431 | static MHD_RESULT | ||
432 | handler_seed (const struct TEH_RequestHandler *rh, | ||
433 | struct MHD_Connection *connection, | ||
434 | const char *const args[]) | ||
435 | { | ||
436 | #define SEED_SIZE 32 | ||
437 | char *body; | ||
438 | MHD_RESULT ret; | ||
439 | struct MHD_Response *resp; | ||
440 | |||
441 | (void) rh; | ||
442 | body = malloc (SEED_SIZE); /* must use malloc(), because MHD will use free() */ | ||
443 | if (NULL == body) | ||
444 | return MHD_NO; | ||
445 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE, | ||
446 | body, | ||
447 | SEED_SIZE); | ||
448 | resp = MHD_create_response_from_buffer (SEED_SIZE, | ||
449 | body, | ||
450 | MHD_RESPMEM_MUST_FREE); | ||
451 | TALER_MHD_add_global_headers (resp); | ||
452 | ret = MHD_queue_response (connection, | ||
453 | MHD_HTTP_OK, | ||
454 | resp); | ||
455 | GNUNET_break (MHD_YES == ret); | ||
456 | MHD_destroy_response (resp); | ||
457 | return ret; | ||
458 | #undef SEED_SIZE | ||
459 | } | ||
460 | |||
461 | |||
462 | /** | ||
424 | * Handle incoming HTTP request. | 463 | * Handle incoming HTTP request. |
425 | * | 464 | * |
426 | * @param cls closure for MHD daemon (unused) | 465 | * @param cls closure for MHD daemon (unused) |
@@ -472,6 +511,11 @@ handle_mhd_request (void *cls, | |||
472 | .method = MHD_HTTP_METHOD_GET, | 511 | .method = MHD_HTTP_METHOD_GET, |
473 | .handler.get = &TEH_handler_agpl_redirect | 512 | .handler.get = &TEH_handler_agpl_redirect |
474 | }, | 513 | }, |
514 | { | ||
515 | .url = "seed", | ||
516 | .method = MHD_HTTP_METHOD_GET, | ||
517 | .handler.get = &handler_seed | ||
518 | }, | ||
475 | /* Terms of service */ | 519 | /* Terms of service */ |
476 | { | 520 | { |
477 | .url = "terms", | 521 | .url = "terms", |
@@ -654,9 +698,10 @@ handle_mhd_request (void *cls, | |||
654 | { | 698 | { |
655 | struct TEH_RequestHandler *rh = &handlers[i]; | 699 | struct TEH_RequestHandler *rh = &handlers[i]; |
656 | 700 | ||
657 | if (0 != strncmp (tok, | 701 | if ( (0 != strncmp (tok, |
658 | rh->url, | 702 | rh->url, |
659 | tok_size)) | 703 | tok_size)) || |
704 | (tok_size != strlen (rh->url) ) ) | ||
660 | continue; | 705 | continue; |
661 | found = GNUNET_YES; | 706 | found = GNUNET_YES; |
662 | /* The URL is a match! What we now do depends on the method. */ | 707 | /* The URL is a match! What we now do depends on the method. */ |
diff --git a/src/testing/test_exchange_api_twisted.c b/src/testing/test_exchange_api_twisted.c index 053372197..c99c7410d 100644 --- a/src/testing/test_exchange_api_twisted.c +++ b/src/testing/test_exchange_api_twisted.c | |||
@@ -205,10 +205,6 @@ run (void *cls, | |||
205 | MHD_HTTP_PRECONDITION_FAILED, | 205 | MHD_HTTP_PRECONDITION_FAILED, |
206 | "EUR:50", | 206 | "EUR:50", |
207 | "deposit-refund-1"), | 207 | "deposit-refund-1"), |
208 | TALER_TESTING_cmd_refund ("refund-fee-too-low", | ||
209 | MHD_HTTP_BAD_REQUEST, | ||
210 | "EUR:5", | ||
211 | "deposit-refund-1"), | ||
212 | TALER_TESTING_cmd_end () | 208 | TALER_TESTING_cmd_end () |
213 | }; | 209 | }; |
214 | 210 | ||