more refactoring for libtalermhd

This commit is contained in:
Christian Grothoff 2019-11-23 21:06:25 +01:00
parent cf6ba0c771
commit 8f006e779e
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
2 changed files with 24 additions and 13 deletions

View File

@ -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;
}

View File

@ -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,