From 15355188d5f6913d9bfa08b45cbb5576c4847801 Mon Sep 17 00:00:00 2001 From: Benjamin Sergeant Date: Tue, 5 May 2020 07:43:55 -0700 Subject: [PATCH] (http client) rework a bit PATCH pull request, fix compile error with setForceBody and initialize _forceBody to false --- ixwebsocket/IXHttpClient.cpp | 19 ++++++++++++++++++- ixwebsocket/IXHttpClient.h | 10 +++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/ixwebsocket/IXHttpClient.cpp b/ixwebsocket/IXHttpClient.cpp index c9a841aa..ef8da7da 100644 --- a/ixwebsocket/IXHttpClient.cpp +++ b/ixwebsocket/IXHttpClient.cpp @@ -30,6 +30,7 @@ namespace ix HttpClient::HttpClient(bool async) : _async(async) , _stop(false) + , _forceBody(false) { if (!_async) return; @@ -50,9 +51,11 @@ namespace ix _tlsOptions = tlsOptions; } - void setForceBody(bool value) { + void HttpClient::setForceBody(bool value) + { _forceBody = value; } + HttpRequestArgsPtr HttpClient::createRequest(const std::string& url, const std::string& verb) { auto request = std::make_shared(); @@ -564,6 +567,20 @@ namespace ix return request(url, kPut, body, args); } + HttpResponsePtr HttpClient::patch(const std::string& url, + const HttpParameters& httpParameters, + HttpRequestArgsPtr args) + { + return request(url, kPatch, serializeHttpParameters(httpParameters), args); + } + + HttpResponsePtr HttpClient::patch(const std::string& url, + const std::string& body, + const HttpRequestArgsPtr args) + { + return request(url, kPatch, body, args); + } + std::string HttpClient::urlEncode(const std::string& value) { std::ostringstream escaped; diff --git a/ixwebsocket/IXHttpClient.h b/ixwebsocket/IXHttpClient.h index e50f708c..f591b1e9 100644 --- a/ixwebsocket/IXHttpClient.h +++ b/ixwebsocket/IXHttpClient.h @@ -46,6 +46,13 @@ namespace ix const std::string& body, HttpRequestArgsPtr args); + HttpResponsePtr patch(const std::string& url, + const HttpParameters& httpParameters, + HttpRequestArgsPtr args); + HttpResponsePtr patch(const std::string& url, + const std::string& body, + HttpRequestArgsPtr args); + HttpResponsePtr request(const std::string& url, const std::string& verb, const std::string& body, @@ -84,7 +91,6 @@ namespace ix void log(const std::string& msg, HttpRequestArgsPtr args); bool gzipInflate(const std::string& in, std::string& out); - bool _forceBody; // Async API background thread runner void run(); @@ -100,5 +106,7 @@ namespace ix std::mutex _mutex; // to protect accessing the _socket (only one socket per client) SocketTLSOptions _tlsOptions; + + bool _forceBody; }; } // namespace ix