aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcello Stanisci <stanisci.m@gmail.com>2018-06-13 18:38:08 +0200
committerMarcello Stanisci <stanisci.m@gmail.com>2018-06-13 18:39:07 +0200
commit1a7fbccc8b3fd6fc070d134892e736503286ef1b (patch)
tree95390f15a2581e43ebbc83fb0ccd9ffcf7c4ff8e
parente532e871ca89b8a78700756fef1284de15f479c8 (diff)
Expanding libgnunetcurl.
Adding a method to let the user append a custom request header.
-rw-r--r--src/curl/curl.c19
-rw-r--r--src/include/gnunet_curl_lib.h11
2 files changed, 30 insertions, 0 deletions
diff --git a/src/curl/curl.c b/src/curl/curl.c
index 2d0b09d92d..cdd39ab8e1 100644
--- a/src/curl/curl.c
+++ b/src/curl/curl.c
@@ -448,6 +448,25 @@ download_get_result (struct DownloadBuffer *db,
/**
+ * Add custom request header.
+ *
+ * @param ctx cURL context.
+ * @param header header string; will be given to the context AS IS.
+ * @return #GNUNET_OK if no errors occurred, #GNUNET_SYSERR otherwise.
+ */
+int
+GNUNET_CURL_append_header (struct GNUNET_CURL_Context *ctx,
+ const char *header)
+{
+ ctx->json_header = curl_slist_append (ctx->json_header,
+ header);
+ if (NULL == ctx->json_header)
+ return GNUNET_SYSERR;
+
+ return GNUNET_OK;
+}
+
+/**
* Run the main event loop for the Taler interaction.
*
* @param ctx the library context
diff --git a/src/include/gnunet_curl_lib.h b/src/include/gnunet_curl_lib.h
index 17e9aeea4b..2b2442a528 100644
--- a/src/include/gnunet_curl_lib.h
+++ b/src/include/gnunet_curl_lib.h
@@ -99,6 +99,17 @@ GNUNET_CURL_get_select_info (struct GNUNET_CURL_Context *ctx,
/**
+ * Add custom request header.
+ *
+ * @param ctx cURL context.
+ * @param header header string; will be given to the context AS IS.
+ * @return #GNUNET_OK if no errors occurred, #GNUNET_SYSERR otherwise.
+ */
+int
+GNUNET_CURL_append_header (struct GNUNET_CURL_Context *ctx,
+ const char *header);
+
+/**
* Run the main event loop for the CURL interaction.
*
* @param ctx the library context