(http client) / Add DEL and PUT method, make requests and other utilities public 👐
This commit is contained in:
		@@ -21,6 +21,8 @@ namespace ix
 | 
				
			|||||||
    const std::string HttpClient::kPost = "POST";
 | 
					    const std::string HttpClient::kPost = "POST";
 | 
				
			||||||
    const std::string HttpClient::kGet = "GET";
 | 
					    const std::string HttpClient::kGet = "GET";
 | 
				
			||||||
    const std::string HttpClient::kHead = "HEAD";
 | 
					    const std::string HttpClient::kHead = "HEAD";
 | 
				
			||||||
 | 
					    const std::string HttpClient::kDel = "DEL";
 | 
				
			||||||
 | 
					    const std::string HttpClient::kPut = "PUT";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    HttpClient::HttpClient()
 | 
					    HttpClient::HttpClient()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@@ -345,6 +347,12 @@ namespace ix
 | 
				
			|||||||
        return request(url, kHead, std::string(), args);
 | 
					        return request(url, kHead, std::string(), args);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    HttpResponse HttpClient::del(const std::string& url,
 | 
				
			||||||
 | 
					                                 const HttpRequestArgs& args)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return request(url, kDel, std::string(), args);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    HttpResponse HttpClient::post(const std::string& url,
 | 
					    HttpResponse HttpClient::post(const std::string& url,
 | 
				
			||||||
                                  const HttpParameters& httpParameters,
 | 
					                                  const HttpParameters& httpParameters,
 | 
				
			||||||
                                  const HttpRequestArgs& args)
 | 
					                                  const HttpRequestArgs& args)
 | 
				
			||||||
@@ -359,6 +367,20 @@ namespace ix
 | 
				
			|||||||
        return request(url, kPost, body, args);
 | 
					        return request(url, kPost, body, args);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    HttpResponse HttpClient::put(const std::string& url,
 | 
				
			||||||
 | 
					                                 const HttpParameters& httpParameters,
 | 
				
			||||||
 | 
					                                 const HttpRequestArgs& args)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return request(url, kPut, serializeHttpParameters(httpParameters), args);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    HttpResponse HttpClient::put(const std::string& url,
 | 
				
			||||||
 | 
					                                 const std::string& body,
 | 
				
			||||||
 | 
					                                 const HttpRequestArgs& args)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return request(url, kPut, body, args);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    std::string HttpClient::urlEncode(const std::string& value)
 | 
					    std::string HttpClient::urlEncode(const std::string& value)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        std::ostringstream escaped;
 | 
					        std::ostringstream escaped;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -71,6 +71,7 @@ namespace ix
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        HttpResponse get(const std::string& url, const HttpRequestArgs& args);
 | 
					        HttpResponse get(const std::string& url, const HttpRequestArgs& args);
 | 
				
			||||||
        HttpResponse head(const std::string& url, const HttpRequestArgs& args);
 | 
					        HttpResponse head(const std::string& url, const HttpRequestArgs& args);
 | 
				
			||||||
 | 
					        HttpResponse del(const std::string& url, const HttpRequestArgs& args);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        HttpResponse post(const std::string& url,
 | 
					        HttpResponse post(const std::string& url,
 | 
				
			||||||
                          const HttpParameters& httpParameters,
 | 
					                          const HttpParameters& httpParameters,
 | 
				
			||||||
@@ -79,7 +80,13 @@ namespace ix
 | 
				
			|||||||
                          const std::string& body,
 | 
					                          const std::string& body,
 | 
				
			||||||
                          const HttpRequestArgs& args);
 | 
					                          const HttpRequestArgs& args);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private:
 | 
					        HttpResponse put(const std::string& url,
 | 
				
			||||||
 | 
					                         const HttpParameters& httpParameters,
 | 
				
			||||||
 | 
					                         const HttpRequestArgs& args);
 | 
				
			||||||
 | 
					        HttpResponse put(const std::string& url,
 | 
				
			||||||
 | 
					                         const std::string& body,
 | 
				
			||||||
 | 
					                         const HttpRequestArgs& args);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        HttpResponse request(const std::string& url,
 | 
					        HttpResponse request(const std::string& url,
 | 
				
			||||||
                             const std::string& verb,
 | 
					                             const std::string& verb,
 | 
				
			||||||
                             const std::string& body,
 | 
					                             const std::string& body,
 | 
				
			||||||
@@ -90,6 +97,7 @@ namespace ix
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        std::string urlEncode(const std::string& value);
 | 
					        std::string urlEncode(const std::string& value);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private:
 | 
				
			||||||
        void log(const std::string& msg, const HttpRequestArgs& args);
 | 
					        void log(const std::string& msg, const HttpRequestArgs& args);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        bool gzipInflate(const std::string& in, std::string& out);
 | 
					        bool gzipInflate(const std::string& in, std::string& out);
 | 
				
			||||||
@@ -99,5 +107,7 @@ namespace ix
 | 
				
			|||||||
        const static std::string kPost;
 | 
					        const static std::string kPost;
 | 
				
			||||||
        const static std::string kGet;
 | 
					        const static std::string kGet;
 | 
				
			||||||
        const static std::string kHead;
 | 
					        const static std::string kHead;
 | 
				
			||||||
 | 
					        const static std::string kDel;
 | 
				
			||||||
 | 
					        const static std::string kPut;
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
} // namespace ix
 | 
					} // namespace ix
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user