summaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-01-18 11:58:00 +0100
committerChristian Grothoff <christian@grothoff.org>2021-01-18 11:58:00 +0100
commitcd47c8e0afb66f2d9053082940f208347551b3a8 (patch)
tree1e50b6a5448cbab3c7422baabc8f6f67e77890ac /src/backend
parentd99be82b37fc00dec9b16822e815216c979d70cd (diff)
downloadmerchant-cd47c8e0afb66f2d9053082940f208347551b3a8.tar.gz
merchant-cd47c8e0afb66f2d9053082940f208347551b3a8.tar.bz2
merchant-cd47c8e0afb66f2d9053082940f208347551b3a8.zip
only log things as ERROR that are actually ERRORs; return 502 instead of 500 on abort failure due to malformed exchange reply
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/taler-merchant-httpd_post-orders-ID-abort.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-abort.c b/src/backend/taler-merchant-httpd_post-orders-ID-abort.c
index 4f6b8667..a7dadb69 100644
--- a/src/backend/taler-merchant-httpd_post-orders-ID-abort.c
+++ b/src/backend/taler-merchant-httpd_post-orders-ID-abort.c
@@ -343,6 +343,7 @@ static void
generate_success_response (struct AbortContext *ac)
{
json_t *refunds;
+ unsigned int hc = MHD_HTTP_OK;
refunds = json_array ();
if (NULL == refunds)
@@ -359,15 +360,22 @@ generate_success_response (struct AbortContext *ac)
struct RefundDetails *rdi = &ac->rd[i];
json_t *detail;
+ if ( (MHD_HTTP_BAD_REQUEST <= rdi->http_status) ||
+ (0 == rdi->http_status) ||
+ (NULL == rdi->exchange_reply) )
+ hc = MHD_HTTP_BAD_GATEWAY;
detail = (MHD_HTTP_OK != rdi->http_status)
- ? json_pack ("{s:s, s:I, s:I, s:O}",
+ ? json_pack ("{s:s, s:I, s:I, s:O?}",
"type",
"failure",
"exchange_status",
(json_int_t) rdi->http_status,
"exchange_code",
- (json_int_t) TALER_JSON_get_error_code (
- rdi->exchange_reply),
+ (json_int_t)
+ (NULL != rdi->exchange_reply)
+ ? TALER_JSON_get_error_code (
+ rdi->exchange_reply)
+ : TALER_EC_GENERIC_INVALID_RESPONSE,
"exchange_reply",
rdi->exchange_reply)
: json_pack ("{s:s, s:I, s:o, s:o}",
@@ -395,7 +403,7 @@ generate_success_response (struct AbortContext *ac)
/* Resume and send back the response. */
resume_abort_with_response (ac,
- MHD_HTTP_OK,
+ hc,
TALER_MHD_make_json_pack ("{s:o}",
"refunds",
refunds));