Add User-Agent header to each HTTP request
This commit is contained in:
parent
46819af36f
commit
a7d9f31747
1 changed files with 3 additions and 1 deletions
4
util.c
4
util.c
|
@ -203,7 +203,7 @@ json_t *json_rpc_call(CURL *curl, const char *url,
|
|||
struct upload_buffer upload_data;
|
||||
json_error_t err = { };
|
||||
struct curl_slist *headers = NULL;
|
||||
char len_hdr[64];
|
||||
char len_hdr[64], user_agent_hdr[128];
|
||||
char curl_err_str[CURL_ERROR_SIZE];
|
||||
long timeout = longpoll ? (60 * 60) : (60 * 10);
|
||||
struct header_info hi = { };
|
||||
|
@ -244,10 +244,12 @@ json_t *json_rpc_call(CURL *curl, const char *url,
|
|||
upload_data.len = strlen(rpc_req);
|
||||
sprintf(len_hdr, "Content-Length: %lu",
|
||||
(unsigned long) upload_data.len);
|
||||
sprintf(user_agent_hdr, "User-Agent: %s", PACKAGE_STRING);
|
||||
|
||||
headers = curl_slist_append(headers,
|
||||
"Content-type: application/json");
|
||||
headers = curl_slist_append(headers, len_hdr);
|
||||
headers = curl_slist_append(headers, user_agent_hdr);
|
||||
headers = curl_slist_append(headers, "Expect:"); /* disable Expect hdr*/
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
|
||||
|
|
Loading…
Reference in a new issue