diff options
author | Christian Grothoff <christian@grothoff.org> | 2024-10-01 14:05:09 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2024-10-01 14:05:09 +0200 |
commit | 1e2a6651223c41f9c3ed09c2e98678d175b0e2cc (patch) | |
tree | 184f1a46d2cd67442098115779d3109bf143382d | |
parent | a5694e741ace840acfe8774a8dc9e3455de4c0cd (diff) |
support 451 response in client API
-rw-r--r-- | src/lib/merchant_api_post_order_pay.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/lib/merchant_api_post_order_pay.c b/src/lib/merchant_api_post_order_pay.c index 14eebd28..d10fc6d7 100644 --- a/src/lib/merchant_api_post_order_pay.c +++ b/src/lib/merchant_api_post_order_pay.c @@ -322,6 +322,52 @@ handle_pay_finished (void *cls, of some disagreement on the PKI). We should pass the JSON reply to the application */ break; + case MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS: + { + json_t *ebus = json_object_get (json, + "exchange_base_urls"); + if (NULL == ebus) + { + GNUNET_break_op (0); + pr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; + pr.hr.http_status = 0; + pr.hr.hint = "failed to parse exchange_base_urls field in response"; + break; + } + { + size_t alen = json_array_size (ebus); + const char *ebua[GNUNET_NZL (alen)]; + size_t idx; + json_t *jebu; + bool ok = true; + + GNUNET_assert (alen <= UINT_MAX); + json_array_foreach (ebus, idx, jebu) + { + ebua[idx] = json_string_value (jebu); + if (NULL == ebua[idx]) + { + GNUNET_break_op (0); + pr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; + pr.hr.http_status = 0; + pr.hr.hint = "non-string value in exchange_base_urls in response"; + ok = false; + break; + } + } + if (! ok) + break; + pr.details.unavailable_for_legal_reasons.num_exchanges + = (unsigned int) alen; + pr.details.unavailable_for_legal_reasons.exchanges + = ebua; + oph->pay_cb (oph->pay_cb_cls, + &pr); + TALER_MERCHANT_order_pay_cancel (oph); + return; + } + } + break; case MHD_HTTP_INTERNAL_SERVER_ERROR: TALER_MERCHANT_parse_error_details_ (json, response_code, |