1 #ifndef __GPUDB__HTTP_HPP__ 2 #define __GPUDB__HTTP_HPP__ 5 #include <boost/asio/ssl.hpp> 17 static const std::string
HTTP;
22 HttpUrl(
const std::string& url);
23 HttpUrl(
const std::string& protocol,
24 const std::string& host,
26 const std::string& path,
27 const std::string& query = std::string());
29 const std::string& path,
30 const std::string& query = std::string());
32 const std::string&
getUrl()
const;
35 const std::string&
getHost()
const;
37 const std::string&
getPath()
const;
46 operator std::string()
const;
56 void init(
const std::string& url);
70 static const std::string
GET;
71 static const std::string
HEAD;
72 static const std::string
POST;
77 #ifndef GPUDB_NO_HTTPS 78 boost::asio::ssl::context* getSslContext();
82 const std::string& getRequestMethod()
const;
83 const std::string& getRequestHeader(
const std::string& key)
const;
84 std::map<std::string, std::string>& getRequestHeaders();
85 size_t getTimeout()
const;
87 #ifndef GPUDB_NO_HTTPS 88 void setSslContext(boost::asio::ssl::context* sslContext);
91 void setUrl(
const HttpUrl& url);
92 void setRequestMethod(
const std::string& method);
93 void addRequestHeader(
const std::string& key,
const std::string& value);
94 void setTimeout(
const size_t timeout);
99 virtual void read(
const void*& data,
size_t& length)
const;
105 #ifndef GPUDB_NO_HTTPS 106 boost::asio::ssl::context* m_sslContext;
110 std::string m_requestMethod;
111 std::map<std::string, std::string> m_requestHeaders;
121 const std::vector<uint8_t>* getRequestBody();
123 void setRequestBody(
const std::vector<uint8_t>* requestBody);
126 virtual void read(
const void*& data,
size_t& length)
const;
129 const std::vector<uint8_t>* m_requestBody;
138 const std::string* getRequestBody();
140 void setRequestBody(
const std::string* requestBody);
143 virtual void read(
const void*& data,
size_t& length)
const;
146 const std::string* m_requestBody;
155 const std::string& getResponseVersion()
const;
156 unsigned int getResponseCode()
const;
157 const std::string& getResponseMessage()
const;
158 const std::string& getResponseHeader(
const std::string& key)
const;
159 const std::map<std::string, std::string>& getResponseHeaders()
const;
162 virtual void write(
const void* data,
const size_t length);
168 std::string m_responseVersion;
169 unsigned int m_responseCode;
170 std::string m_responseMessage;
171 std::map<std::string, std::string> m_responseHeaders;
177 const std::vector<uint8_t>& getResponseBody()
const;
180 virtual void write(
const void* data,
const size_t length);
183 std::vector<uint8_t> m_responseBody;
189 const std::string& getResponseBody()
const;
192 virtual void write(
const void* data,
const size_t length);
195 std::string m_responseBody;
const std::string & getProtocol() const
static const std::string POST
std::ostream & operator<<(std::ostream &stream, const HttpUrl &value)
static const std::string HTTPS
static const std::string GET
static const std::string HTTP
const std::string & getHost() const
const std::string & getQuery() const
std::string getAppendedUrl(const std::string &endpoint) const
Returns a string with the passed in endpoint appended to this URL.
const std::string & getUrl() const
static const std::string HEAD
const std::string & getPath() const