aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-11-23 21:06:25 +0100
committerChristian Grothoff <christian@grothoff.org>2019-11-23 21:06:25 +0100
commit8f006e779e12fed604182faa096ebe6b5726d04d (patch)
treeff0f9bfefb194a06354832253072532f15110505
parentcf6ba0c77196b77f5c54f0533ac1be3d1d5ee6d6 (diff)
more refactoring for libtalermhd
-rw-r--r--src/exchange/taler-exchange-httpd_db.c31
-rw-r--r--src/exchange/taler-exchange-httpd_keystate.c6
2 files changed, 24 insertions, 13 deletions
diff --git a/src/exchange/taler-exchange-httpd_db.c b/src/exchange/taler-exchange-httpd_db.c
index 37bd23792..19781f97f 100644
--- a/src/exchange/taler-exchange-httpd_db.c
+++ b/src/exchange/taler-exchange-httpd_db.c
@@ -23,6 +23,7 @@
#include <jansson.h>
#include <gnunet/gnunet_json_lib.h>
#include "taler_json_lib.h"
+#include "taler_mhd_lib.h"
#include "taler-exchange-httpd_responses.h"
#include "taler-exchange-httpd_keystate.h"
@@ -62,8 +63,10 @@ TEH_DB_know_coin_transaction (void *cls,
if (GNUNET_DB_STATUS_HARD_ERROR == qs)
{
*mhd_ret
- = TEH_RESPONSE_reply_internal_db_error (connection,
- TALER_EC_DB_COIN_HISTORY_STORE_ERROR);
+ = TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_DB_COIN_HISTORY_STORE_ERROR,
+ "could not persist coin data");
return GNUNET_DB_STATUS_HARD_ERROR;
}
return qs;
@@ -99,8 +102,10 @@ TEH_DB_run_transaction (struct MHD_Connection *connection,
{
GNUNET_break (0);
if (NULL != mhd_ret)
- *mhd_ret = TEH_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,
+ "could not establish database session");
return GNUNET_SYSERR;
}
TEH_plugin->preflight (TEH_plugin->cls,
@@ -117,8 +122,10 @@ TEH_DB_run_transaction (struct MHD_Connection *connection,
{
GNUNET_break (0);
if (NULL != mhd_ret)
- *mhd_ret = TEH_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,
+ "could not begin transaction");
return GNUNET_SYSERR;
}
qs = cb (cb_cls,
@@ -136,8 +143,10 @@ TEH_DB_run_transaction (struct MHD_Connection *connection,
if (GNUNET_DB_STATUS_HARD_ERROR == qs)
{
if (NULL != mhd_ret)
- *mhd_ret = TEH_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,
+ "could not commit database transaction");
return GNUNET_SYSERR;
}
/* make sure callback did not violate invariants! */
@@ -150,8 +159,10 @@ TEH_DB_run_transaction (struct MHD_Connection *connection,
name,
MAX_TRANSACTION_COMMIT_RETRIES);
if (NULL != mhd_ret)
- *mhd_ret = TEH_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,
+ "repatedly failed to serialize database transaction");
return GNUNET_SYSERR;
}
diff --git a/src/exchange/taler-exchange-httpd_keystate.c b/src/exchange/taler-exchange-httpd_keystate.c
index 7297a741b..cf5cbe9a0 100644
--- a/src/exchange/taler-exchange-httpd_keystate.c
+++ b/src/exchange/taler-exchange-httpd_keystate.c
@@ -1243,7 +1243,7 @@ setup_general_response_headers (const struct TEH_KS_StateHandle *key_state,
{
char dat[128];
- TEH_RESPONSE_add_global_headers (response);
+ TALER_MHD_add_global_headers (response);
GNUNET_break (MHD_YES ==
MHD_add_response_header (response,
MHD_HTTP_HEADER_CONTENT_TYPE,
@@ -1546,8 +1546,8 @@ build_keys_response (const struct ResponseFactoryContext *rfc,
}
/* Also compute compressed version of /keys response */
- comp = TEH_RESPONSE_body_compress (&keys_jsonz,
- &keys_jsonz_size);
+ comp = TALER_MHD_body_compress (&keys_jsonz,
+ &keys_jsonz_size);
krd->response_compressed
= MHD_create_response_from_buffer (keys_jsonz_size,
keys_jsonz,