Expanding libgnunetcurl.
authorMarcello Stanisci <stanisci.m@gmail.com>
Wed, 13 Jun 2018 16:38:08 +0000 (18:38 +0200)
committerMarcello Stanisci <stanisci.m@gmail.com>
Wed, 13 Jun 2018 16:39:07 +0000 (18:39 +0200)
Adding a method to let the user append
a custom request header.

src/curl/curl.c
src/include/gnunet_curl_lib.h

index 2d0b09d92d1c46da30d4c21ba86ba4098ebbc863..cdd39ab8e1af8ba14e69b8bd9971b6747a269475 100644 (file)
@@ -447,6 +447,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.
  *
index 17e9aeea4b10e408e5e10b00ef9a537aced51d57..2b2442a528193a5a3395034d563af0a9255cdcaf 100644 (file)
@@ -98,6 +98,17 @@ GNUNET_CURL_get_select_info (struct GNUNET_CURL_Context *ctx,
                              long *timeout);
 
 
+/**
+ * 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.
  *