Simplify HttpClient Interface
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
#ifndef HTTPREQUEST_H
|
||||
#define HTTPREQUEST_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace Http {
|
||||
|
||||
class HttpRequest
|
||||
{
|
||||
public:
|
||||
struct Method
|
||||
{
|
||||
enum type
|
||||
{
|
||||
GET,
|
||||
HEAD,
|
||||
POST,
|
||||
PUT,
|
||||
DELETE,
|
||||
CONNECT,
|
||||
TRACE,
|
||||
PATCH
|
||||
};
|
||||
};
|
||||
|
||||
struct ReturnType
|
||||
{
|
||||
enum type
|
||||
{
|
||||
None,
|
||||
Code,
|
||||
Content,
|
||||
Redirect
|
||||
};
|
||||
};
|
||||
|
||||
public:
|
||||
HttpRequest(const std::string url);
|
||||
~HttpRequest();
|
||||
|
||||
HttpRequest::Method::type Method() const;
|
||||
void Method(HttpRequest::Method::type method);
|
||||
HttpRequest::ReturnType::type ReturnType() const;
|
||||
void ReturnType(HttpRequest::ReturnType::type returnType);
|
||||
|
||||
std::string URL() const;
|
||||
void URL(const std::string& url);
|
||||
std::vector<std::string> Headers() const;
|
||||
void Headers(const std::vector<std::string>& headers);
|
||||
std::string Data() const;
|
||||
void Data(const std::string& data);
|
||||
|
||||
std::string CookieFile() const;
|
||||
void CookieFile(const std::string& cookieFile);
|
||||
|
||||
std::string Filename() const;
|
||||
void Filename(const std::string& filename);
|
||||
std::string FileFieldname() const;
|
||||
void FileFieldname(const std::string& fileFieldname);
|
||||
|
||||
private:
|
||||
HttpRequest::Method::type m_method;
|
||||
HttpRequest::ReturnType::type m_returnType;
|
||||
|
||||
std::string m_url;
|
||||
std::vector<std::string> m_headers;
|
||||
std::string m_data;
|
||||
|
||||
std::string m_cookieFile;
|
||||
|
||||
std::string m_filename;
|
||||
std::string m_fileFieldname;
|
||||
};
|
||||
|
||||
} // namespace Http
|
||||
|
||||
#endif // HTTPREQUEST_H
|
||||
Reference in New Issue
Block a user