diff options
author | horchi <vdr@jwendel.de> | 2020-07-28 12:23:04 +0200 |
---|---|---|
committer | horchi <vdr@jwendel.de> | 2020-07-28 12:23:04 +0200 |
commit | 04b0ae3e8101fc36a9df3aa07bf9e6dfdf1b0d38 (patch) | |
tree | df3e33b7579a71aaf826253e2a8fd222045faa3c /lib | |
parent | 8d38dfabb114d8a93c34ce1258d97e389f5645d9 (diff) | |
download | vdr-epg-daemon-04b0ae3e8101fc36a9df3aa07bf9e6dfdf1b0d38.tar.gz vdr-epg-daemon-04b0ae3e8101fc36a9df3aa07bf9e6dfdf1b0d38.tar.bz2 |
2020-07-28: version 1.1.162 (Alexander Grothe, horchi)\n - change: Improved curl handling\n\n1.1.162
Diffstat (limited to 'lib')
-rw-r--r-- | lib/curl.c | 10 | ||||
-rw-r--r-- | lib/test.c | 22 |
2 files changed, 24 insertions, 8 deletions
@@ -99,6 +99,10 @@ int cCurl::init(const char* httpproxy) return fail; } } + else + { + curl_easy_reset(handle); + } // Reset Options @@ -451,10 +455,11 @@ int cCurl::downloadFile(const char* url, int& size, MemoryStruct* data, int time long httpCode = 0; curl_easy_getinfo(handle, CURLINFO_RESPONSE_CODE, &httpCode); - tell(1, "Error: Download failed; %s (%d); http code was (%ld) [%s]", - curl_easy_strerror(res), res, httpCode, url); + tell(1, "Error: Download failed, got %ld bytes; %s (%d); http code was (%ld) [%s]", + data->size, curl_easy_strerror(res), res, httpCode, url); data->clear(); + exit(); return fail; } @@ -465,6 +470,7 @@ int cCurl::downloadFile(const char* url, int& size, MemoryStruct* data, int time if (code == 404) { data->clear(); + exit(); return fail; } @@ -666,26 +666,36 @@ int main(int argc, char** argv) char* url = 0; MemoryStruct data; - data.clear(); + curl.init(""); if (strncmp(argv[1], "http", 4) == 0) asprintf(&url, "%s", argv[1]); else - asprintf(&url, "%s/eplist.cgi?action=show&file=%s", - "www.eplists.de", argv[1]); + asprintf(&url, "%s/eplist.cgi?action=show&file=%s", "www.eplists.de", argv[1]); tell(0, "try to download [%s]", url); - if (curl.downloadFile(url, size, &data) == success) + data.clear(); + data.headerOnly = yes; + + if (curl.downloadFile(url, size, &data, 30, "libcurl-agent/1.0") == success) + tell(0, "Got header for '%s-%s' with %d bytes", data.name, data.tag, size); + else + tell(0, "downloadFile failed!"); + + data.clear(); + + if (curl.downloadFile(url, size, &data, 30, "libcurl-agent/1.0") == success) { tell(0, "succeeded!"); - tell(0, "Got: !"); + tell(0, "Got: %d bytes", size); tell(0, "%s", data.memory); + storeToFile("./data", data.memory, size); + tell(0, "stored to './data'"); } else tell(0, "FAILED!"); - free(url); return 0; |