hack in bank-lib compression

This commit is contained in:
Florian Dold 2019-05-12 21:59:55 +02:00
parent 4b36b6c964
commit 7fa67030a8
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
2 changed files with 22 additions and 42 deletions

View File

@ -42,7 +42,8 @@ libtalerbank_la_SOURCES = \
bank_api_common.c bank_api_common.h \ bank_api_common.c bank_api_common.h \
bank_api_history.c \ bank_api_history.c \
bank_api_reject.c \ bank_api_reject.c \
bank_api_parse.c bank_api_parse.c \
../lib/teah_common.c # FIXME: ugly hack!!
libtalerbank_la_LIBADD = \ libtalerbank_la_LIBADD = \
$(top_builddir)/src/json/libtalerjson.la \ $(top_builddir)/src/json/libtalerjson.la \

View File

@ -23,6 +23,8 @@
#include "bank_api_common.h" #include "bank_api_common.h"
#include <microhttpd.h> /* just for HTTP status codes */ #include <microhttpd.h> /* just for HTTP status codes */
#include "taler_signatures.h" #include "taler_signatures.h"
// FIXME(dold): temporary hack
#include "../lib/teah_common.h"
/** /**
@ -37,20 +39,15 @@ struct TALER_BANK_AdminAddIncomingHandle
char *request_url; char *request_url;
/** /**
* JSON encoding of the request to POST. * POST context.
*/ */
char *json_enc; struct TEAH_PostContext *post_ctx;
/** /**
* Handle for the request. * Handle for the request.
*/ */
struct GNUNET_CURL_Job *job; struct GNUNET_CURL_Job *job;
/**
* HTTP authentication-related headers for the request.
*/
struct curl_slist *authh;
/** /**
* Function to call with the result. * Function to call with the result.
*/ */
@ -192,6 +189,7 @@ TALER_BANK_admin_add_incoming (struct GNUNET_CURL_Context *ctx,
struct TALER_BANK_AdminAddIncomingHandle *aai; struct TALER_BANK_AdminAddIncomingHandle *aai;
json_t *admin_obj; json_t *admin_obj;
CURL *eh; CURL *eh;
struct curl_slist *headers = NULL;
if (NULL == exchange_base_url) if (NULL == exchange_base_url)
{ {
@ -215,45 +213,28 @@ TALER_BANK_admin_add_incoming (struct GNUNET_CURL_Context *ctx,
aai->cb_cls = res_cb_cls; aai->cb_cls = res_cb_cls;
aai->request_url = TALER_BANK_path_to_url_ (bank_base_url, aai->request_url = TALER_BANK_path_to_url_ (bank_base_url,
"/admin/add/incoming"); "/admin/add/incoming");
aai->authh = TALER_BANK_make_auth_header_ (auth); headers = TALER_BANK_make_auth_header_ (auth);
/* Append content type header here, can't do it in GNUNET_CURL_job_add
as that would override the CURLOPT_HTTPHEADER instead of appending. */
{
struct curl_slist *ext;
ext = curl_slist_append (aai->authh, GNUNET_assert (NULL !=
"Content-Type: application/json"); (headers = curl_slist_append (headers,
if (NULL == ext) "Content-Type: application/json")));
GNUNET_break (0);
else
aai->authh = ext;
}
eh = curl_easy_init (); eh = curl_easy_init ();
GNUNET_assert (NULL != (aai->json_enc =
json_dumps (admin_obj, GNUNET_assert (GNUNET_OK ==
JSON_COMPACT))); TEAH_curl_easy_post (aai->post_ctx, eh, admin_obj));
json_decref (admin_obj); json_decref (admin_obj);
GNUNET_assert (CURLE_OK ==
curl_easy_setopt (eh,
CURLOPT_HTTPHEADER,
aai->authh));
GNUNET_assert (CURLE_OK == GNUNET_assert (CURLE_OK ==
curl_easy_setopt (eh, curl_easy_setopt (eh,
CURLOPT_URL, CURLOPT_URL,
aai->request_url)); aai->request_url));
GNUNET_assert (CURLE_OK ==
curl_easy_setopt (eh, aai->job = GNUNET_CURL_job_add2 (ctx,
CURLOPT_POSTFIELDS, eh,
aai->json_enc)); headers,
GNUNET_assert (CURLE_OK == &handle_admin_add_incoming_finished,
curl_easy_setopt (eh, aai);
CURLOPT_POSTFIELDSIZE,
strlen (aai->json_enc)));
aai->job = GNUNET_CURL_job_add (ctx,
eh,
GNUNET_NO,
&handle_admin_add_incoming_finished,
aai);
return aai; return aai;
} }
@ -272,9 +253,7 @@ TALER_BANK_admin_add_incoming_cancel (struct TALER_BANK_AdminAddIncomingHandle *
GNUNET_CURL_job_cancel (aai->job); GNUNET_CURL_job_cancel (aai->job);
aai->job = NULL; aai->job = NULL;
} }
curl_slist_free_all (aai->authh);
GNUNET_free (aai->request_url); GNUNET_free (aai->request_url);
GNUNET_free (aai->json_enc);
GNUNET_free (aai); GNUNET_free (aai);
} }