-fix 200 vs. 204 in fakebank

This commit is contained in:
Christian Grothoff 2022-12-19 14:37:20 +01:00
parent 80660f2d88
commit c4cc1ea13d
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC

View File

@ -2257,23 +2257,20 @@ handle_debit_history (struct TALER_FAKEBANK_Handle *h,
if ( (NULL == t) || if ( (NULL == t) ||
overflow) overflow)
{ {
GNUNET_free (debit_payto);
if (GNUNET_TIME_relative_is_zero (ha.lp_timeout) && if (GNUNET_TIME_relative_is_zero (ha.lp_timeout) &&
(0 < ha.delta)) (0 < ha.delta))
{ {
GNUNET_assert (0 == GNUNET_assert (0 ==
pthread_mutex_unlock (&h->big_lock)); pthread_mutex_unlock (&h->big_lock));
if (overflow) if (overflow)
{
GNUNET_free (debit_payto);
return TALER_MHD_reply_with_ec ( return TALER_MHD_reply_with_ec (
connection, connection,
TALER_EC_BANK_ANCIENT_TRANSACTION_GONE, TALER_EC_BANK_ANCIENT_TRANSACTION_GONE,
NULL); NULL);
return TALER_MHD_REPLY_JSON_PACK ( }
connection, goto finish;
MHD_HTTP_OK,
GNUNET_JSON_pack_array_steal (
"outgoing_transactions",
history));
} }
*con_cls = &special_ptr; *con_cls = &special_ptr;
start_lp (h, start_lp (h,
@ -2285,6 +2282,7 @@ handle_debit_history (struct TALER_FAKEBANK_Handle *h,
GNUNET_assert (0 == GNUNET_assert (0 ==
pthread_mutex_unlock (&h->big_lock)); pthread_mutex_unlock (&h->big_lock));
json_decref (history); json_decref (history);
GNUNET_free (debit_payto);
return MHD_YES; return MHD_YES;
} }
if (t->debit_account != acc) if (t->debit_account != acc)
@ -2397,6 +2395,16 @@ handle_debit_history (struct TALER_FAKEBANK_Handle *h,
} }
GNUNET_assert (0 == GNUNET_assert (0 ==
pthread_mutex_unlock (&h->big_lock)); pthread_mutex_unlock (&h->big_lock));
finish:
if (0 == json_array_size (history))
{
json_decref (history);
return TALER_MHD_reply_static (connection,
MHD_HTTP_NO_CONTENT,
NULL,
NULL,
0);
}
GNUNET_free (debit_payto); GNUNET_free (debit_payto);
return TALER_MHD_REPLY_JSON_PACK (connection, return TALER_MHD_REPLY_JSON_PACK (connection,
MHD_HTTP_OK, MHD_HTTP_OK,
@ -2500,11 +2508,7 @@ handle_credit_history (struct TALER_FAKEBANK_Handle *h,
connection, connection,
TALER_EC_BANK_ANCIENT_TRANSACTION_GONE, TALER_EC_BANK_ANCIENT_TRANSACTION_GONE,
NULL); NULL);
return TALER_MHD_REPLY_JSON_PACK (connection, goto finish;
MHD_HTTP_OK,
GNUNET_JSON_pack_array_steal (
"incoming_transactions",
history));
} }
*con_cls = &special_ptr; *con_cls = &special_ptr;
start_lp (h, start_lp (h,
@ -2608,6 +2612,16 @@ handle_credit_history (struct TALER_FAKEBANK_Handle *h,
} }
GNUNET_assert (0 == GNUNET_assert (0 ==
pthread_mutex_unlock (&h->big_lock)); pthread_mutex_unlock (&h->big_lock));
finish:
if (0 == json_array_size (history))
{
json_decref (history);
return TALER_MHD_reply_static (connection,
MHD_HTTP_NO_CONTENT,
NULL,
NULL,
0);
}
return TALER_MHD_REPLY_JSON_PACK (connection, return TALER_MHD_REPLY_JSON_PACK (connection,
MHD_HTTP_OK, MHD_HTTP_OK,
GNUNET_JSON_pack_array_steal ( GNUNET_JSON_pack_array_steal (