diff options
author | Brandon Williams <bmwill@google.com> | 2018-03-15 18:31:38 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-03-15 20:01:09 +0100 |
commit | 8ff14ed4127decbee3116aba59d7f8f897c4fe3b (patch) | |
tree | 19a7798c9d5169c47ab0667aa786330c72849a60 | |
parent | remote-curl: store the protocol version the server responded with (diff) | |
download | git-8ff14ed4127decbee3116aba59d7f8f897c4fe3b.tar.xz git-8ff14ed4127decbee3116aba59d7f8f897c4fe3b.zip |
http: allow providing extra headers for http requests
Add a way for callers to request that extra headers be included when
making http requests.
Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | http.c | 8 | ||||
-rw-r--r-- | http.h | 7 |
2 files changed, 15 insertions, 0 deletions
@@ -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"); @@ -172,6 +172,13 @@ struct http_get_options { * for details. */ struct strbuf *base_url; + + /* + * If not NULL, contains additional HTTP headers to be sent with the + * request. The strings in the list must not be freed until after the + * request has completed. + */ + struct string_list *extra_headers; }; /* Return values for http_get_*() */ |