aboutsummaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2011-03-22 13:58:32 -0400
committerJeff Garzik <jgarzik@pobox.com>2011-03-22 13:58:32 -0400
commita7d9f31747a6bff71c3ea6955996d402ef72d538 (patch)
treeddb9872903caaed9908f006e757c577ca73e07ec /util.c
parent46819af36f0ae94e69333810ad0a03f472fc6d8e (diff)
Add User-Agent header to each HTTP request
Diffstat (limited to 'util.c')
-rw-r--r--util.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/util.c b/util.c
index 58533f2..d5dc781 100644
--- a/util.c
+++ b/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);