added read-url

This commit is contained in:
2021-02-09 19:36:05 +01:00
parent 22f9410d17
commit 982241acf6
8 changed files with 315 additions and 7 deletions

32
clib/sslclient.h Normal file
View File

@@ -0,0 +1,32 @@
#include <openssl/err.h>
#include <openssl/ssl.h>
#include <string>
#include <unordered_map>
class HttpClient {
// TODO at this moment only https is implemented
private:
SSL *ssl;
int sock;
std::string full_url, proto, server, port, uri, params, href;
std::basic_string<char> ssl_read_packet;
std::unordered_map<std::string, std::string> headers_map;
public:
HttpClient();
std::pair<int, std::string> doGetRequest(const std::string &url, const std::unordered_map<std::string, std::string> &headers);
private:
std::string inetAddress(std::string hostname);
int sslRecvPacket();
int sslSendPacket(std::string buf);
int sslRequest(const std::string &server_name, const std::string &request);
void log_ssl();
};