mirror of
https://github.com/davidallendj/gdpm.git
synced 2025-12-20 03:27:02 -07:00
Minor bug fixes and improvements
- Update `README.md` file with minor changes - Added `max_results` parameter to config for persistence - Added `csv2`, `tabulate`, and `indicators` as included dependencies - Added downloading progress bar that *sometimes* work -Added HTTP request header handling with curl - Added more options to some commands - Moved `http` functions into `context` class TODO: Fix optional parameters not working correctly NOTE: Github does not always return `Content-length` HTTP response header
This commit is contained in:
parent
a3e4c054c2
commit
460e2054c2
15 changed files with 408 additions and 101 deletions
|
|
@ -3,9 +3,12 @@
|
|||
#include "constants.hpp"
|
||||
#include "types.hpp"
|
||||
#include <unordered_map>
|
||||
#include <curl/curl.h>
|
||||
#include <curl/easy.h>
|
||||
|
||||
namespace gdpm::http{
|
||||
using headers_t = std::unordered_map<string, string>;
|
||||
using header = std::pair<string, string>;
|
||||
|
||||
// REF: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
|
||||
enum response_code{
|
||||
|
|
@ -88,9 +91,25 @@ namespace gdpm::http{
|
|||
int verbose = 0;
|
||||
};
|
||||
|
||||
string url_escape(const string& url);
|
||||
response request_get(const string& url, const http::request_params& params = http::request_params());
|
||||
response request_post(const string& url, const http::request_params& params = http::request_params());
|
||||
response download_file(const string& url, const string& storage_path, const http::request_params& params = http::request_params());
|
||||
class context : public non_copyable{
|
||||
public:
|
||||
context();
|
||||
~context();
|
||||
|
||||
inline CURL* const get_curl() const;
|
||||
string url_escape(const string& url);
|
||||
response request_get(const string& url, const http::request_params& params = http::request_params());
|
||||
response request_post(const string& url, const http::request_params& params = http::request_params());
|
||||
response download_file(const string& url, const string& storage_path, const http::request_params& params = http::request_params());
|
||||
long get_download_size(const string& url);
|
||||
long get_bytes_downloaded(const string& url);
|
||||
|
||||
private:
|
||||
CURL *curl;
|
||||
curl_slist* _add_headers(CURL *curl, const headers_t& headers);
|
||||
};
|
||||
|
||||
|
||||
|
||||
extern context http;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue