summaryrefslogtreecommitdiff
path: root/src/lib/exchange_api_reserve.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-05-03 17:36:58 +0200
committerChristian Grothoff <christian@grothoff.org>2019-05-03 17:37:07 +0200
commita16c32a4745634b77439200ee4831fed2811fd8a (patch)
treefa5f43337a727e6d88c4be4e28de9105ca6141ae /src/lib/exchange_api_reserve.c
parent5dd3c2191af0bb28a95fe4dac09eae7ed672cd48 (diff)
downloadexchange-a16c32a4745634b77439200ee4831fed2811fd8a.tar.gz
exchange-a16c32a4745634b77439200ee4831fed2811fd8a.tar.bz2
exchange-a16c32a4745634b77439200ee4831fed2811fd8a.zip
add compression support for bodies of POST/PUT operations
Diffstat (limited to 'src/lib/exchange_api_reserve.c')
-rw-r--r--src/lib/exchange_api_reserve.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/lib/exchange_api_reserve.c b/src/lib/exchange_api_reserve.c
index 66509bc5..ae0bd01d 100644
--- a/src/lib/exchange_api_reserve.c
+++ b/src/lib/exchange_api_reserve.c
@@ -677,9 +677,10 @@ struct TALER_EXCHANGE_ReserveWithdrawHandle
char *url;
/**
- * JSON encoding of the request to POST.
+ * Context for #TEH_curl_easy_post(). Keeps the data that must
+ * persist for Curl to make the upload.
*/
- char *json_enc;
+ struct TEAH_PostContext ctx;
/**
* Handle for the request.
@@ -1022,25 +1023,26 @@ reserve_withdraw_internal (struct TALER_EXCHANGE_Handle *exchange,
if (NULL == withdraw_obj)
{
GNUNET_break (0);
+ GNUNET_free (wsh);
return NULL;
}
wsh->ps = *ps;
wsh->url = TEAH_path_to_url (exchange, "/reserve/withdraw");
-
eh = TEL_curl_easy_get (wsh->url);
- GNUNET_assert (NULL != (wsh->json_enc =
- json_dumps (withdraw_obj,
- JSON_COMPACT)));
+ if (GNUNET_OK !=
+ TEAH_curl_easy_post (&wsh->ctx,
+ eh,
+ withdraw_obj))
+ {
+ GNUNET_break (0);
+ curl_easy_cleanup (eh);
+ json_decref (withdraw_obj);
+ GNUNET_free (wsh->url);
+ GNUNET_free (wsh);
+ return NULL;
+ }
json_decref (withdraw_obj);
- GNUNET_assert (CURLE_OK ==
- curl_easy_setopt (eh,
- CURLOPT_POSTFIELDS,
- wsh->json_enc));
- GNUNET_assert (CURLE_OK ==
- curl_easy_setopt (eh,
- CURLOPT_POSTFIELDSIZE,
- strlen (wsh->json_enc)));
ctx = TEAH_handle_to_context (exchange);
wsh->job = GNUNET_CURL_job_add (ctx,
eh,
@@ -1199,7 +1201,7 @@ TALER_EXCHANGE_reserve_withdraw_cancel (struct TALER_EXCHANGE_ReserveWithdrawHan
sign->job = NULL;
}
GNUNET_free (sign->url);
- GNUNET_free (sign->json_enc);
+ TEAH_curl_easy_post_finished (&sign->ctx);
GNUNET_free (sign);
}