deal more nicely with /keys failures where no JSON is returned

This commit is contained in:
Christian Grothoff 2021-05-27 11:19:56 +02:00
parent 3986c9ae2d
commit 35ce352b16
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC

View File

@ -1214,11 +1214,34 @@ keys_completed_cb (void *cls,
exchange->key_data_raw = json_deep_copy (j); exchange->key_data_raw = json_deep_copy (j);
exchange->retry_delay = GNUNET_TIME_UNIT_ZERO; exchange->retry_delay = GNUNET_TIME_UNIT_ZERO;
break; 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: default:
if (MHD_HTTP_GATEWAY_TIMEOUT == response_code) if (MHD_HTTP_GATEWAY_TIMEOUT == response_code)
exchange->keys_error_count++; exchange->keys_error_count++;
hr.ec = TALER_JSON_get_error_code (j); if (NULL == j)
hr.hint = TALER_JSON_get_error_hint (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, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u/%d\n", "Unexpected response code %u/%d\n",
(unsigned int) response_code, (unsigned int) response_code,