summaryrefslogtreecommitdiff
path: root/src/lib/exchange_api_lookup_aml_decision.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/exchange_api_lookup_aml_decision.c')
-rw-r--r--src/lib/exchange_api_lookup_aml_decision.c45
1 files changed, 36 insertions, 9 deletions
diff --git a/src/lib/exchange_api_lookup_aml_decision.c b/src/lib/exchange_api_lookup_aml_decision.c
index c10919165..04b1d52aa 100644
--- a/src/lib/exchange_api_lookup_aml_decision.c
+++ b/src/lib/exchange_api_lookup_aml_decision.c
@@ -56,6 +56,10 @@ struct TALER_EXCHANGE_LookupAmlDecision
*/
void *decision_cb_cls;
+ /**
+ * HTTP headers for the job.
+ */
+ struct curl_slist *job_headers;
};
@@ -118,7 +122,7 @@ handle_lookup_finished (void *cls,
break;
}
GNUNET_assert (NULL == lh->decision_cb);
- TALER_EXCHANGE_link_cancel (lh);
+ TALER_EXCHANGE_lookup_aml_decision_cancel (lh);
return;
case MHD_HTTP_BAD_REQUEST:
lr.hr.ec = TALER_JSON_get_error_code (j);
@@ -152,14 +156,14 @@ handle_lookup_finished (void *cls,
if (NULL != lh->decision_cb)
lh->decision_cb (lh->decision_cb_cls,
&lr);
- TALER_EXCHANGE_link_cancel (lh);
+ TALER_EXCHANGE_lookup_aml_decision_cancel (lh);
}
struct TALER_EXCHANGE_LookupAmlDecision *
TALER_EXCHANGE_lookup_aml_decision (
struct GNUNET_CURL_Context *ctx,
- const char *url,
+ const char *exchange_url,
const struct TALER_PaytoHashP *h_payto,
const struct TALER_AmlOfficerPrivateKeyP *officer_priv,
TALER_EXCHANGE_LookupAmlDecisionCallback cb,
@@ -202,7 +206,7 @@ TALER_EXCHANGE_lookup_aml_decision (
lh = GNUNET_new (struct TALER_EXCHANGE_LookupAmlDecision);
lh->decision_cb = cb;
lh->decision_cb_cls = cb_cls;
- lh->url = TALER_URL_join (exchange_url,
+ lh->url = TALER_url_join (exchange_url,
arg_str,
NULL);
if (NULL == lh->url)
@@ -218,11 +222,33 @@ TALER_EXCHANGE_lookup_aml_decision (
GNUNET_free (lh);
return NULL;
}
- // FIXME: add authorization header to 'eh' based on officer_sig!
- lh->job = GNUNET_CURL_job_add_with_ct_json (ctx,
- eh,
- &handle_lookup_finished,
- lh);
+ {
+ char *hdr;
+ char sig_str[sizeof (officer_sig) * 2];
+ char *end;
+
+ end = GNUNET_STRINGS_data_to_string (
+ &officer_sig,
+ sizeof (officer_sig),
+ sig_str,
+ sizeof (sig_str));
+ *end = '\0';
+
+ GNUNET_asprintf (&hdr,
+ "%s: %s",
+ TALER_AML_OFFICER_SIGNATURE_HEADER,
+ sig_str);
+ lh->job_headers = curl_slist_append (NULL,
+ hdr);
+ GNUNET_free (hdr);
+ lh->job_headers = curl_slist_append (lh->job_headers,
+ "Content-type: application/json");
+ lh->job = GNUNET_CURL_job_add2 (ctx,
+ eh,
+ lh->job_headers,
+ &handle_lookup_finished,
+ lh);
+ }
return lh;
}
@@ -236,6 +262,7 @@ TALER_EXCHANGE_lookup_aml_decision_cancel (
GNUNET_CURL_job_cancel (lh->job);
lh->job = NULL;
}
+ curl_slist_free_all (lh->job_headers);
GNUNET_free (lh->url);
GNUNET_free (lh);
}