57 lines
1.5 KiB
C++
57 lines
1.5 KiB
C++
#ifndef CTAICURL_H
|
|
#define CTAICURL_H
|
|
|
|
#include <QObject>
|
|
#include <QDir>
|
|
#include <QFile>
|
|
#include <QtConcurrent/QtConcurrent>
|
|
#include "curl/curl.h"
|
|
#include "curl/easy.h"
|
|
#include <QDateTime>
|
|
#include "3rdparty/json/json.hpp"
|
|
#include "ctai_base.h"
|
|
#include <regex>
|
|
using json = nlohmann::json;
|
|
|
|
class ctaiCurl : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
ctaiCurl();
|
|
~ctaiCurl();
|
|
void curl_init();
|
|
void send_post_response(model_data,curl_opts);
|
|
void send_stream(model_data &, std::string response_data);
|
|
void send_not_stream(model_data &, std::string response_data);
|
|
public:
|
|
std::mutex m_mutex;
|
|
private:
|
|
CURL *m_curl;
|
|
curl_slist *m_headers;
|
|
CURLcode m_error;
|
|
model_data c_data;
|
|
curl_opts c_opts;
|
|
bool m_initialized; // 添加初始化状态标志
|
|
void set_send_post_option();
|
|
void set_send_post_opts_reset();
|
|
std::string send_send_body(model_data);
|
|
std::vector<std::string> steam_extract(const std::string &input);
|
|
void set_send_post_headers(std::string head_str);
|
|
void set_curl_ssl(bool);
|
|
void set_curl_timeout(int time);
|
|
void set_curl_followlocation(bool followlocation_state);
|
|
void set_curl_debug_verbose(bool verbose_state);
|
|
void set_curl_tcp_keepalive(bool keepalive_state);
|
|
std::string send_timestamp_to_time(time_t timestamp);
|
|
signals:
|
|
void send_post_out_data(model_data out_data);
|
|
void send_post_out_error(std::string);
|
|
};
|
|
|
|
typedef struct call_back_context
|
|
{
|
|
ctaiCurl *instance;
|
|
model_data m_data;
|
|
} call_back_context;
|
|
|
|
#endif |