-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
supports file download with redirect, json parse, last version downlo…
…ad, version comparison, md5 calculation
- Loading branch information
Showing
9 changed files
with
479 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
FROM decenomy/dsw-linux-x64-builder@sha256:49894f78ac27318ed1c018c80e674f99e6b45ac382c9b98a2aa0c94d8bd755a4 | ||
#FROM decenomy/dsw-linux-x64-builder@sha256:49894f78ac27318ed1c018c80e674f99e6b45ac382c9b98a2aa0c94d8bd755a4 | ||
FROM decenomy/local-linux-x64-builder:latest | ||
|
||
# Set up a development tools directory | ||
WORKDIR /home/app | ||
|
||
COPY . /home/app | ||
|
||
RUN make clean | ||
RUN make docker_linux_test | ||
|
||
RUN export PATH="/wrapped:$PATH" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include "httpclient.h" | ||
|
||
HTTPClient::HTTPClient() { | ||
curl_global_init(CURL_GLOBAL_ALL); | ||
curl = curl_easy_init(); | ||
if (!curl) { | ||
std::cerr << "Error: Failed to initialize libcurl." << std::endl; | ||
} | ||
} | ||
|
||
HTTPClient::~HTTPClient() { | ||
if (curl) { | ||
curl_easy_cleanup(curl); | ||
} | ||
curl_global_cleanup(); | ||
} | ||
|
||
std::string HTTPClient::get(const std::string& url) { | ||
|
||
std::cout << "get info from: " << url << std::endl; | ||
std::string response; | ||
if (curl) { | ||
curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); | ||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L); // Verify the peer's SSL certificate | ||
curl_easy_setopt(curl, CURLOPT_SSL_OPTIONS, CURLSSLOPT_NATIVE_CA); | ||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writeCallback); | ||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response); | ||
|
||
// Set User-Agent header | ||
curl_version_info_data *info = curl_version_info(CURLVERSION_NOW); | ||
|
||
if (info) { | ||
curl_easy_setopt(curl, CURLOPT_USERAGENT, info->version); | ||
} | ||
|
||
CURLcode res = curl_easy_perform(curl); | ||
if (res != CURLE_OK) { | ||
std::cerr << "Error: Failed to perform HTTP request: " << curl_easy_strerror(res) << std::endl; | ||
} | ||
} | ||
return response; | ||
} | ||
|
||
size_t HTTPClient::writeCallback(void* ptr, size_t size, size_t nmemb, std::string* data) { | ||
data->append((char*)ptr, size * nmemb); | ||
return size * nmemb; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#ifndef HTTPCLIENT_H | ||
#define HTTPCLIENT_H | ||
|
||
#include <string> | ||
#include <curl/curl.h> | ||
#include <iostream> | ||
|
||
class HTTPClient { | ||
public: | ||
HTTPClient(); | ||
~HTTPClient(); | ||
std::string get(const std::string& url); | ||
|
||
private: | ||
CURL* curl; | ||
static size_t writeCallback(void* ptr, size_t size, size_t nmemb, std::string* data); | ||
}; | ||
|
||
#endif // HTTPCLIENT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.