diff options
author | Petri Lehtinen <petri@digip.org> | 2013-12-27 08:55:52 +0200 |
---|---|---|
committer | Petri Lehtinen <petri@digip.org> | 2013-12-27 08:55:52 +0200 |
commit | 9c8b3c833fe484f5e853f2e82f82ce3f97cc1679 (patch) | |
tree | 874d846acf5e7e357c9f6f670b00c76a33558e2a /doc | |
parent | 4e8c4bfbd209e50cc7b13993bbd56adb9282c465 (diff) | |
parent | dc69aa797bbf3c2605edaafb677153b5a4e662a9 (diff) | |
download | jansson-9c8b3c833fe484f5e853f2e82f82ce3f97cc1679.zip jansson-9c8b3c833fe484f5e853f2e82f82ce3f97cc1679.tar.gz jansson-9c8b3c833fe484f5e853f2e82f82ce3f97cc1679.tar.bz2 |
Merge branch '2.5'
Diffstat (limited to 'doc')
-rw-r--r-- | doc/github_commits.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/doc/github_commits.c b/doc/github_commits.c index 2b39250..94fb8b7 100644 --- a/doc/github_commits.c +++ b/doc/github_commits.c @@ -53,6 +53,7 @@ static char *request(const char *url) { CURL *curl = NULL; CURLcode status; + struct curl_slist *headers = NULL; char *data = NULL; long code; @@ -71,6 +72,11 @@ static char *request(const char *url) }; curl_easy_setopt(curl, CURLOPT_URL, url); + + /* GitHub commits API v3 requires a User-Agent header */ + headers = curl_slist_append(headers, "User-Agent: Jansson-Tutorial"); + curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_response); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &write_result); @@ -90,6 +96,7 @@ static char *request(const char *url) } curl_easy_cleanup(curl); + curl_slist_free_all(headers); curl_global_cleanup(); /* zero-terminate the result */ @@ -102,6 +109,8 @@ error: free(data); if(curl) curl_easy_cleanup(curl); + if(headers) + curl_slist_free_all(headers); curl_global_cleanup(); return NULL; } |