mirror of
https://github.com/openappsec/openappsec.git
synced 2025-11-16 09:21:54 +03:00
sync code
This commit is contained in:
76
core/include/internal/curl_http_client.h
Normal file
76
core/include/internal/curl_http_client.h
Normal file
@@ -0,0 +1,76 @@
|
||||
#ifndef __CURL_HTTP_CLIENT_H__
|
||||
#define __CURL_HTTP_CLIENT_H__
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <curl/curl.h>
|
||||
#include "messaging/http_response.h"
|
||||
#include "i_http_client.h"
|
||||
|
||||
class CurlHttpClient : public I_HttpClient
|
||||
{
|
||||
public:
|
||||
CurlHttpClient();
|
||||
~CurlHttpClient();
|
||||
|
||||
void setProxy(const std::string& hosts) override;
|
||||
void setBasicAuth(const std::string& username, const std::string& password) override;
|
||||
void authEnabled(bool enabled) override;
|
||||
|
||||
HTTPResponse
|
||||
get(
|
||||
const std::string& url,
|
||||
const std::map<std::string, std::string>& headers = {}
|
||||
) override;
|
||||
|
||||
HTTPResponse
|
||||
post(
|
||||
const std::string& url,
|
||||
const std::string& data,
|
||||
const std::map<std::string, std::string>& headers = {}
|
||||
) override;
|
||||
|
||||
HTTPResponse
|
||||
put(
|
||||
const std::string& url,
|
||||
const std::string& body,
|
||||
const std::map<std::string, std::string>& headers = {}
|
||||
) override; HTTPResponse
|
||||
patch(
|
||||
const std::string& url,
|
||||
const std::string& body,
|
||||
const std::map<std::string, std::string>& headers = {}
|
||||
) override;
|
||||
|
||||
HTTPResponse
|
||||
del(
|
||||
const std::string& url,
|
||||
const std::map<std::string, std::string>& headers = {}
|
||||
) override;
|
||||
|
||||
private:
|
||||
static size_t
|
||||
WriteCallback(
|
||||
void *contents,
|
||||
size_t size,
|
||||
size_t nmemb,
|
||||
std::string *userp
|
||||
);
|
||||
|
||||
HTTPResponse
|
||||
perform_request(
|
||||
const std::string& method,
|
||||
const std::string& url,
|
||||
const std::string& body,
|
||||
const std::map<std::string, std::string>& headers
|
||||
);
|
||||
|
||||
std::string no_proxy_hosts;
|
||||
bool auth_enabled;
|
||||
std::string username;
|
||||
std::string password;
|
||||
};
|
||||
|
||||
#endif // __CURL_HTTP_CLIENT_H__
|
||||
|
||||
50
core/include/services_sdk/interfaces/i_http_client.h
Normal file
50
core/include/services_sdk/interfaces/i_http_client.h
Normal file
@@ -0,0 +1,50 @@
|
||||
#ifndef __I_HTTP_CLIENT_H__
|
||||
#define __I_HTTP_CLIENT_H__
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include "messaging/http_response.h"
|
||||
|
||||
class I_HttpClient
|
||||
{
|
||||
public:
|
||||
virtual ~I_HttpClient() = default;
|
||||
virtual void setProxy(const std::string& hosts) = 0;
|
||||
virtual void setBasicAuth(const std::string& username, const std::string& password) = 0;
|
||||
virtual void authEnabled(bool enabled) = 0;
|
||||
|
||||
virtual HTTPResponse
|
||||
get(
|
||||
const std::string& url,
|
||||
const std::map<std::string, std::string>& headers = {}
|
||||
) = 0;
|
||||
|
||||
virtual HTTPResponse
|
||||
post(
|
||||
const std::string& url,
|
||||
const std::string& data,
|
||||
const std::map<std::string, std::string>& headers = {}
|
||||
) = 0;
|
||||
|
||||
virtual HTTPResponse
|
||||
put(
|
||||
const std::string& url,
|
||||
const std::string& body,
|
||||
const std::map<std::string, std::string>& headers = {}
|
||||
) = 0;
|
||||
|
||||
virtual HTTPResponse
|
||||
patch(
|
||||
const std::string& url,
|
||||
const std::string& body,
|
||||
const std::map<std::string, std::string>& headers = {}
|
||||
) = 0;
|
||||
|
||||
virtual HTTPResponse
|
||||
del(
|
||||
const std::string& url,
|
||||
const std::map<std::string, std::string>& headers = {}
|
||||
) = 0;
|
||||
};
|
||||
|
||||
#endif // __I_HTTP_CLIENT_H__
|
||||
Reference in New Issue
Block a user