diff options
Diffstat (limited to 'src/lib/exchange_api_curl_defaults.c')
-rw-r--r-- | src/lib/exchange_api_curl_defaults.c | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/src/lib/exchange_api_curl_defaults.c b/src/lib/exchange_api_curl_defaults.c index 82d3ace13..85a32189b 100644 --- a/src/lib/exchange_api_curl_defaults.c +++ b/src/lib/exchange_api_curl_defaults.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2018 Taler Systems SA + Copyright (C) 2014-2018, 2021 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -19,16 +19,11 @@ * @brief curl easy handle defaults * @author Florian Dold */ - +#include "platform.h" +#include "taler_curl_lib.h" #include "exchange_api_curl_defaults.h" -/** - * Get a curl handle with the right defaults for the exchange lib. In the - * future, we might manage a pool of connections here. - * - * @param url URL to query - */ CURL * TALER_EXCHANGE_curl_easy_get_ (const char *url) { @@ -36,21 +31,22 @@ TALER_EXCHANGE_curl_easy_get_ (const char *url) eh = curl_easy_init (); if (NULL == eh) + { + GNUNET_break (0); return NULL; + } GNUNET_assert (CURLE_OK == curl_easy_setopt (eh, CURLOPT_URL, url)); - GNUNET_assert (CURLE_OK == - curl_easy_setopt (eh, - CURLOPT_FOLLOWLOCATION, - 1L)); - /* limit MAXREDIRS to 5 as a simple security measure against - a potential infinite loop caused by a malicious target */ - GNUNET_assert (CURLE_OK == - curl_easy_setopt (eh, - CURLOPT_MAXREDIRS, - 5L)); + TALER_curl_set_secure_redirect_policy (eh, + url); + /* Enable compression (using whatever curl likes), see + https://curl.se/libcurl/c/CURLOPT_ACCEPT_ENCODING.html */ + GNUNET_break (CURLE_OK == + curl_easy_setopt (eh, + CURLOPT_ACCEPT_ENCODING, + "")); GNUNET_assert (CURLE_OK == curl_easy_setopt (eh, CURLOPT_TCP_FASTOPEN, |