Skip to content

remote-curl: unbreak http.extraHeader with custom allocators #453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions http.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ static unsigned long empty_auth_useless =

static struct curl_slist *pragma_header;
static struct curl_slist *no_pragma_header;
static struct curl_slist *extra_http_headers;
static struct string_list extra_http_headers = STRING_LIST_INIT_DUP;

static struct active_request_slot *active_queue_head;

Expand Down Expand Up @@ -414,11 +414,9 @@ static int http_options(const char *var, const char *value, void *cb)
if (!value) {
return config_error_nonbool(var);
} else if (!*value) {
curl_slist_free_all(extra_http_headers);
extra_http_headers = NULL;
string_list_clear(&extra_http_headers, 0);
} else {
extra_http_headers =
curl_slist_append(extra_http_headers, value);
string_list_append(&extra_http_headers, value);
}
return 0;
}
Expand Down Expand Up @@ -1199,8 +1197,7 @@ void http_cleanup(void)
#endif
curl_global_cleanup();

curl_slist_free_all(extra_http_headers);
extra_http_headers = NULL;
string_list_clear(&extra_http_headers, 0);

curl_slist_free_all(pragma_header);
pragma_header = NULL;
Expand Down Expand Up @@ -1624,10 +1621,11 @@ int run_one_slot(struct active_request_slot *slot,

struct curl_slist *http_copy_default_headers(void)
{
struct curl_slist *headers = NULL, *h;
struct curl_slist *headers = NULL;
const struct string_list_item *item;

for (h = extra_http_headers; h; h = h->next)
headers = curl_slist_append(headers, h->data);
for_each_string_list_item(item, &extra_http_headers)
headers = curl_slist_append(headers, item->string);

return headers;
}
Expand Down