From e8a88392da98c3325ba39b20901a5c220158d1f5 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 23 Nov 2019 18:47:07 +0100 Subject: more refactoring towards using libtalermhd --- src/auditor/taler-auditor-httpd_mhd.c | 40 +++++++---------------------------- 1 file changed, 8 insertions(+), 32 deletions(-) (limited to 'src/auditor/taler-auditor-httpd_mhd.c') diff --git a/src/auditor/taler-auditor-httpd_mhd.c b/src/auditor/taler-auditor-httpd_mhd.c index 5f13691f5..6613ddb0d 100644 --- a/src/auditor/taler-auditor-httpd_mhd.c +++ b/src/auditor/taler-auditor-httpd_mhd.c @@ -28,6 +28,8 @@ #include #include #include +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd_responses.h" #include "taler-auditor-httpd_responses.h" #include "taler-auditor-httpd.h" #include "taler-auditor-httpd_mhd.h" @@ -94,38 +96,12 @@ TAH_MHD_handler_agpl_redirect (struct TAH_RequestHandler *rh, const char *upload_data, size_t *upload_data_size) { - const char *agpl = - "This server is licensed under the Affero GPL. You will now be redirected to the source code."; - struct MHD_Response *response; - int ret; - - response = MHD_create_response_from_buffer (strlen (agpl), - (void *) agpl, - MHD_RESPMEM_PERSISTENT); - if (NULL == response) - { - GNUNET_break (0); - return MHD_NO; - } - TAH_RESPONSE_add_global_headers (response); - if (NULL != rh->mime_type) - (void) MHD_add_response_header (response, - MHD_HTTP_HEADER_CONTENT_TYPE, - rh->mime_type); - if (MHD_NO == - MHD_add_response_header (response, - MHD_HTTP_HEADER_LOCATION, - "http://www.git.taler.net/?p=auditor.git")) - { - GNUNET_break (0); - MHD_destroy_response (response); - return MHD_NO; - } - ret = MHD_queue_response (connection, - rh->response_code, - response); - MHD_destroy_response (response); - return ret; + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + return TALER_MHD_reply_agpl (connection, + "http://www.git.taler.net/?p=exchange.git"); } -- cgit v1.2.3 From 7510b6310b59967a21e3683a13b8232179f7b26a Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 23 Nov 2019 22:26:11 +0100 Subject: more libtalermhd migration --- src/auditor/taler-auditor-httpd.c | 7 +++--- src/auditor/taler-auditor-httpd_db.c | 27 ++++++++++++++-------- .../taler-auditor-httpd_deposit-confirmation.c | 1 - src/auditor/taler-auditor-httpd_exchanges.c | 1 - src/auditor/taler-auditor-httpd_mhd.c | 14 +++++------ 5 files changed, 27 insertions(+), 23 deletions(-) (limited to 'src/auditor/taler-auditor-httpd_mhd.c') diff --git a/src/auditor/taler-auditor-httpd.c b/src/auditor/taler-auditor-httpd.c index bf1e7ac71..55a343776 100644 --- a/src/auditor/taler-auditor-httpd.c +++ b/src/auditor/taler-auditor-httpd.c @@ -31,7 +31,6 @@ #include "taler_auditordb_lib.h" #include "taler-auditor-httpd_deposit-confirmation.h" #include "taler-auditor-httpd_exchanges.h" -#include "taler-auditor-httpd_responses.h" #include "taler-auditor-httpd_mhd.h" #include "taler-auditor-httpd.h" @@ -332,9 +331,9 @@ handle_version (struct TAH_RequestHandler *rh, GNUNET_break (0); return MHD_NO; } - return TAH_RESPONSE_reply_json (connection, - ver, - MHD_HTTP_OK); + return TALER_MHD_reply_json (connection, + ver, + MHD_HTTP_OK); } diff --git a/src/auditor/taler-auditor-httpd_db.c b/src/auditor/taler-auditor-httpd_db.c index e0ab8f2e1..3433e9a9f 100644 --- a/src/auditor/taler-auditor-httpd_db.c +++ b/src/auditor/taler-auditor-httpd_db.c @@ -23,8 +23,9 @@ #include #include #include "taler_json_lib.h" +#include "taler_mhd_lib.h" #include "taler-auditor-httpd_db.h" -#include "taler-auditor-httpd_responses.h" +#include "taler-auditor-httpd.h" /** @@ -63,8 +64,10 @@ TAH_DB_run_transaction (struct MHD_Connection *connection, { GNUNET_break (0); if (NULL != mhd_ret) - *mhd_ret = TAH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_DB_SETUP_FAILED); + *mhd_ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_DB_SETUP_FAILED, + "failed to establish session with database"); return GNUNET_SYSERR; } // TAH_plugin->preflight (TAH_plugin->cls, session); // FIXME: needed? @@ -79,8 +82,10 @@ TAH_DB_run_transaction (struct MHD_Connection *connection, { GNUNET_break (0); if (NULL != mhd_ret) - *mhd_ret = TAH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_DB_START_FAILED); + *mhd_ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_DB_START_FAILED, + "failed to begin transaction"); return GNUNET_SYSERR; } qs = cb (cb_cls, @@ -98,8 +103,10 @@ TAH_DB_run_transaction (struct MHD_Connection *connection, if (GNUNET_DB_STATUS_HARD_ERROR == qs) { if (NULL != mhd_ret) - *mhd_ret = TAH_RESPONSE_reply_commit_error (connection, - TALER_EC_DB_COMMIT_FAILED_HARD); + *mhd_ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_DB_COMMIT_FAILED_HARD, + "failed to commit transaction"); return GNUNET_SYSERR; } /* make sure callback did not violate invariants! */ @@ -112,8 +119,10 @@ TAH_DB_run_transaction (struct MHD_Connection *connection, name, MAX_TRANSACTION_COMMIT_RETRIES); if (NULL != mhd_ret) - *mhd_ret = TAH_RESPONSE_reply_commit_error (connection, - TALER_EC_DB_COMMIT_FAILED_ON_RETRY); + *mhd_ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_DB_COMMIT_FAILED_ON_RETRY, + "transaction repeatedly failed to serialize"); return GNUNET_SYSERR; } diff --git a/src/auditor/taler-auditor-httpd_deposit-confirmation.c b/src/auditor/taler-auditor-httpd_deposit-confirmation.c index 23ea14a9f..0a121fdae 100644 --- a/src/auditor/taler-auditor-httpd_deposit-confirmation.c +++ b/src/auditor/taler-auditor-httpd_deposit-confirmation.c @@ -31,7 +31,6 @@ #include "taler-auditor-httpd.h" #include "taler-auditor-httpd_db.h" #include "taler-auditor-httpd_deposit-confirmation.h" -#include "taler-auditor-httpd_responses.h" /** diff --git a/src/auditor/taler-auditor-httpd_exchanges.c b/src/auditor/taler-auditor-httpd_exchanges.c index 27b339636..3c6bfe68f 100644 --- a/src/auditor/taler-auditor-httpd_exchanges.c +++ b/src/auditor/taler-auditor-httpd_exchanges.c @@ -29,7 +29,6 @@ #include "taler-auditor-httpd.h" #include "taler-auditor-httpd_db.h" #include "taler-auditor-httpd_exchanges.h" -#include "taler-auditor-httpd_responses.h" /** diff --git a/src/auditor/taler-auditor-httpd_mhd.c b/src/auditor/taler-auditor-httpd_mhd.c index 6613ddb0d..ca87b8dac 100644 --- a/src/auditor/taler-auditor-httpd_mhd.c +++ b/src/auditor/taler-auditor-httpd_mhd.c @@ -29,8 +29,6 @@ #include #include #include "taler_mhd_lib.h" -#include "taler-auditor-httpd_responses.h" -#include "taler-auditor-httpd_responses.h" #include "taler-auditor-httpd.h" #include "taler-auditor-httpd_mhd.h" @@ -65,7 +63,7 @@ TAH_MHD_handler_static_response (struct TAH_RequestHandler *rh, GNUNET_break (0); return MHD_NO; } - TAH_RESPONSE_add_global_headers (response); + TALER_MHD_add_global_headers (response); if (NULL != rh->mime_type) (void) MHD_add_response_header (response, MHD_HTTP_HEADER_CONTENT_TYPE, @@ -123,11 +121,11 @@ TAH_MHD_handler_send_json_pack_error (struct TAH_RequestHandler *rh, const char *upload_data, size_t *upload_data_size) { - return TAH_RESPONSE_reply_json_pack (connection, - rh->response_code, - "{s:s}", - "error", - rh->data); + return TALER_MHD_reply_json_pack (connection, + rh->response_code, + "{s:s}", + "error", + rh->data); } -- cgit v1.2.3 From 633ae7edd1a80f1abb2fdc751d487cbed2fd6a29 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 23 Nov 2019 22:27:27 +0100 Subject: cleanup --- src/auditor/taler-auditor-httpd_mhd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/auditor/taler-auditor-httpd_mhd.c') diff --git a/src/auditor/taler-auditor-httpd_mhd.c b/src/auditor/taler-auditor-httpd_mhd.c index ca87b8dac..01927469e 100644 --- a/src/auditor/taler-auditor-httpd_mhd.c +++ b/src/auditor/taler-auditor-httpd_mhd.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014 GNUnet e.V. + Copyright (C) 2014-2019 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software @@ -53,6 +53,9 @@ TAH_MHD_handler_static_response (struct TAH_RequestHandler *rh, struct MHD_Response *response; int ret; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; if (0 == rh->data_size) rh->data_size = strlen ((const char *) rh->data); response = MHD_create_response_from_buffer (rh->data_size, -- cgit v1.2.3