start attachments (image paste and upload)

This commit is contained in:
ouwou
2022-06-05 21:41:57 -04:00
parent 4ec5c1dfcc
commit 270730d9b3
15 changed files with 418 additions and 54 deletions

View File

@@ -1,4 +1,5 @@
#pragma once
#include <array>
#include <string>
#include <curl/curl.h>
@@ -98,13 +99,24 @@ struct response {
struct request {
request(EMethod method, std::string url);
request(request &&other) noexcept;
~request();
request(const request &) = delete;
request &operator=(const request &) = delete;
request &operator=(request &&) noexcept = delete;
const std::string &get_url() const;
const char *get_method() const;
void set_verify_ssl(bool verify);
void set_proxy(const std::string &proxy);
void set_header(const std::string &name, const std::string &value);
void set_body(const std::string &data);
void set_user_agent(const std::string &data);
void make_form();
void add_file(std::string_view name, std::string_view file_path, std::string_view filename);
void add_field(std::string_view name, const char *data, size_t size);
response execute();
@@ -115,7 +127,8 @@ private:
std::string m_url;
const char *m_method;
curl_slist *m_header_list = nullptr;
char m_error_buf[CURL_ERROR_SIZE] = { 0 };
std::array<char, CURL_ERROR_SIZE> m_error_buf = { 0 };
curl_mime *m_form = nullptr;
};
using response_type = response;