From 35ce352b16cf1b9fa4ea17a272522d43e29f8656 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 27 May 2021 11:19:56 +0200 Subject: [PATCH] deal more nicely with /keys failures where no JSON is returned --- src/lib/exchange_api_handle.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/lib/exchange_api_handle.c b/src/lib/exchange_api_handle.c index 3adef7b4d..ddf30f2bf 100644 --- a/src/lib/exchange_api_handle.c +++ b/src/lib/exchange_api_handle.c @@ -1214,11 +1214,34 @@ keys_completed_cb (void *cls, exchange->key_data_raw = json_deep_copy (j); exchange->retry_delay = GNUNET_TIME_UNIT_ZERO; break; + case MHD_HTTP_BAD_REQUEST: + case MHD_HTTP_UNAUTHORIZED: + case MHD_HTTP_FORBIDDEN: + case MHD_HTTP_NOT_FOUND: + if (NULL == j) + { + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; + hr.hint = TALER_ErrorCode_get_hint (hr.ec); + } + else + { + hr.ec = TALER_JSON_get_error_code (j); + hr.hint = TALER_JSON_get_error_hint (j); + } + break; default: if (MHD_HTTP_GATEWAY_TIMEOUT == response_code) exchange->keys_error_count++; - hr.ec = TALER_JSON_get_error_code (j); - hr.hint = TALER_JSON_get_error_hint (j); + if (NULL == j) + { + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; + hr.hint = TALER_ErrorCode_get_hint (hr.ec); + } + else + { + hr.ec = TALER_JSON_get_error_code (j); + hr.hint = TALER_JSON_get_error_hint (j); + } GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unexpected response code %u/%d\n", (unsigned int) response_code,