diff options
author | Jeff Garzik <jeff@garzik.org> | 2011-03-22 13:58:32 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2011-03-22 13:58:32 -0400 |
commit | a7d9f31747a6bff71c3ea6955996d402ef72d538 (patch) | |
tree | ddb9872903caaed9908f006e757c577ca73e07ec | |
parent | 46819af36f0ae94e69333810ad0a03f472fc6d8e (diff) |
Add User-Agent header to each HTTP request
-rw-r--r-- | util.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -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); |