diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-05-03 17:36:58 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-05-03 17:37:07 +0200 |
commit | a16c32a4745634b77439200ee4831fed2811fd8a (patch) | |
tree | fa5f43337a727e6d88c4be4e28de9105ca6141ae /src/lib/exchange_api_refresh.c | |
parent | 5dd3c2191af0bb28a95fe4dac09eae7ed672cd48 (diff) |
add compression support for bodies of POST/PUT operations
Diffstat (limited to 'src/lib/exchange_api_refresh.c')
-rw-r--r-- | src/lib/exchange_api_refresh.c | 60 |
1 files changed, 32 insertions, 28 deletions
diff --git a/src/lib/exchange_api_refresh.c b/src/lib/exchange_api_refresh.c index 4b2de2f45..30025d778 100644 --- a/src/lib/exchange_api_refresh.c +++ b/src/lib/exchange_api_refresh.c @@ -834,9 +834,10 @@ struct TALER_EXCHANGE_RefreshMeltHandle 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. @@ -1206,18 +1207,19 @@ TALER_EXCHANGE_refresh_melt (struct TALER_EXCHANGE_Handle *exchange, rmh->url = TEAH_path_to_url (exchange, "/refresh/melt"); eh = TEL_curl_easy_get (rmh->url); - GNUNET_assert (NULL != (rmh->json_enc = - json_dumps (melt_obj, - JSON_COMPACT))); + if (GNUNET_OK != + TEAH_curl_easy_post (&rmh->ctx, + eh, + melt_obj)) + { + GNUNET_break (0); + curl_easy_cleanup (eh); + json_decref (melt_obj); + GNUNET_free (rmh->url); + GNUNET_free (rmh); + return NULL; + } json_decref (melt_obj); - GNUNET_assert (CURLE_OK == - curl_easy_setopt (eh, - CURLOPT_POSTFIELDS, - rmh->json_enc)); - GNUNET_assert (CURLE_OK == - curl_easy_setopt (eh, - CURLOPT_POSTFIELDSIZE, - strlen (rmh->json_enc))); ctx = TEAH_handle_to_context (exchange); rmh->job = GNUNET_CURL_job_add (ctx, eh, @@ -1245,7 +1247,7 @@ TALER_EXCHANGE_refresh_melt_cancel (struct TALER_EXCHANGE_RefreshMeltHandle *rmh free_melt_data (rmh->md); /* does not free 'md' itself */ GNUNET_free (rmh->md); GNUNET_free (rmh->url); - GNUNET_free (rmh->json_enc); + TEAH_curl_easy_post_finished (&rmh->ctx); GNUNET_free (rmh); } @@ -1270,9 +1272,10 @@ struct TALER_EXCHANGE_RefreshRevealHandle 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. @@ -1634,18 +1637,19 @@ TALER_EXCHANGE_refresh_reveal (struct TALER_EXCHANGE_Handle *exchange, "/refresh/reveal"); eh = TEL_curl_easy_get (rrh->url); - GNUNET_assert (NULL != (rrh->json_enc = - json_dumps (reveal_obj, - JSON_COMPACT))); + if (GNUNET_OK != + TEAH_curl_easy_post (&rrh->ctx, + eh, + reveal_obj)) + { + GNUNET_break (0); + curl_easy_cleanup (eh); + json_decref (reveal_obj); + GNUNET_free (rrh->url); + GNUNET_free (rrh); + return NULL; + } json_decref (reveal_obj); - GNUNET_assert (CURLE_OK == - curl_easy_setopt (eh, - CURLOPT_POSTFIELDS, - rrh->json_enc)); - GNUNET_assert (CURLE_OK == - curl_easy_setopt (eh, - CURLOPT_POSTFIELDSIZE, - strlen (rrh->json_enc))); ctx = TEAH_handle_to_context (rrh->exchange); rrh->job = GNUNET_CURL_job_add (ctx, eh, @@ -1671,7 +1675,7 @@ TALER_EXCHANGE_refresh_reveal_cancel (struct TALER_EXCHANGE_RefreshRevealHandle rrh->job = NULL; } GNUNET_free (rrh->url); - GNUNET_free (rrh->json_enc); + TEAH_curl_easy_post_finished (&rrh->ctx); free_melt_data (rrh->md); /* does not free 'md' itself */ GNUNET_free (rrh->md); GNUNET_free (rrh); |