diff options
author | Florian Dold <florian.dold@gmail.com> | 2018-01-31 17:47:01 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2018-01-31 17:47:01 +0100 |
commit | 3859a40f24e27ae6b825f0f4163d43bc95cc10d3 (patch) | |
tree | 33836fa86d89fc47d74d6d108bdca45aa159c707 /src/include | |
parent | 6f9354cac6a4c3d015475777a2249dfeff0fa641 (diff) | |
download | exchange-3859a40f24e27ae6b825f0f4163d43bc95cc10d3.tar.xz |
url construction helpers
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/taler_util.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/include/taler_util.h b/src/include/taler_util.h index 84d4f5dee..407521c6e 100644 --- a/src/include/taler_util.h +++ b/src/include/taler_util.h @@ -22,6 +22,7 @@ #define TALER_UTIL_H #include <gnunet/gnunet_util_lib.h> +#include <microhttpd.h> #include "taler_amount_lib.h" #include "taler_crypto_lib.h" @@ -134,4 +135,62 @@ const struct GNUNET_OS_ProjectData * TALER_project_data_default (void); +/** + * URL-encode a string according to rfc3986. + * + * @param s string to encode + * @returns the urlencoded string, the caller must free it with GNUNET_free + */ +char * +TALER_urlencode (const char *s); + + +/** + * Make an absolute URL with query parameters. + * + * @param base_url absolute base URL to use + * @param path path of the url + * @param ... NULL-terminated key-value pairs (char *) for query parameters, + * only the value will be url-encoded + * @returns the URL, must be freed with #GNUNET_free + */ +char * +TALER_url_join (const char *base_url, + const char *path, + ...); + + +/** + * Make an absolute URL for the given parameters. + * + * @param proto protocol for the URL (typically https) + * @param host hostname for the URL + * @param prefix prefix for the URL + * @param path path for the URL + * @param ... NULL-terminated key-value pairs (char *) for query parameters, + * the value will be url-encoded + * @returns the URL, must be freed with #GNUNET_free + */ +char * +TALER_url_absolute_raw (const char *proto, + const char *host, + const char *prefix, + const char *path, + ...); + + +/** + * Make an absolute URL for a given MHD connection. + * + * @param path path of the url + * @param ... NULL-terminated key-value pairs (char *) for query parameters, + * the value will be url-encoded + * @returns the URL, must be freed with #GNUNET_free + */ +char * +TALER_url_absolute_mhd (struct MHD_Connection *connection, + const char *path, + ...); + + #endif |