Thread (329 messages) 329 messages, 12 authors, 2018-03-14
STALE3030d
Revisions (4)
  1. v3 current
  2. v4 [diff vs current]
  3. v5 [diff vs current]
  4. v6 [diff vs current]

[PATCH v3 32/35] http: allow providing extra headers for http requests

From: Brandon Williams <hidden>
Date: 2018-02-07 01:14:37
Subsystem: the rest · Maintainer: Linus Torvalds

Add a way for callers to request that extra headers be included when
making http requests.

Signed-off-by: Brandon Williams <redacted>
---
 http.c | 8 ++++++++
 http.h | 2 ++
 2 files changed, 10 insertions(+)
diff --git a/http.c b/http.c
index 597771271..e1757d62b 100644
--- a/http.c
+++ b/http.c
@@ -1723,6 +1723,14 @@ static int http_request(const char *url,
 
 	headers = curl_slist_append(headers, buf.buf);
 
+	/* Add additional headers here */
+	if (options && options->extra_headers) {
+		const struct string_list_item *item;
+		for_each_string_list_item(item, options->extra_headers) {
+			headers = curl_slist_append(headers, item->string);
+		}
+	}
+
 	curl_easy_setopt(slot->curl, CURLOPT_URL, url);
 	curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, headers);
 	curl_easy_setopt(slot->curl, CURLOPT_ENCODING, "gzip");
diff --git a/http.h b/http.h
index f7bd3b26b..a113915c7 100644
--- a/http.h
+++ b/http.h
@@ -172,6 +172,8 @@ struct http_get_options {
 	 * for details.
 	 */
 	struct strbuf *base_url;
+
+	struct string_list *extra_headers;
 };
 
 /* Return values for http_get_*() */
-- 
2.16.0.rc1.238.g530d649a79-goog
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help