From d47ee877be5d1175bdc36f2d87881ddaf875a8e9 Mon Sep 17 00:00:00 2001 From: Oleg Morozenkov Date: Mon, 23 Jul 2018 01:56:42 +0300 Subject: Refactor http clients, fix webhook server, add more samples, change tabs to 4 spaces --- include/tgbot/net/HttpParser.h | 34 +++++++--------------------------- 1 file changed, 7 insertions(+), 27 deletions(-) (limited to 'include/tgbot/net/HttpParser.h') diff --git a/include/tgbot/net/HttpParser.h b/include/tgbot/net/HttpParser.h index d40619a..d4900a1 100644 --- a/include/tgbot/net/HttpParser.h +++ b/include/tgbot/net/HttpParser.h @@ -35,33 +35,13 @@ namespace TgBot { class HttpParser { public: - static HttpParser& getInstance(); - - std::string generateRequest(const Url& url, const std::vector& args, bool isKeepAlive = false); - std::string generateMultipartFormData(const std::vector& args, const std::string& bondary); - std::string generateMultipartBoundary(const std::vector& args); - std::string generateWwwFormUrlencoded(const std::vector& args); - std::string generateResponse(const std::string& data, const std::string& mimeType = "text/plain", short unsigned statusCode = 200, const std::string& statusStr = "OK", bool isKeepAlive = false); - - inline std::string parseRequest(const std::string& data, std::unordered_map& headers) { - return parseHttp(true, data, headers); - } - - inline std::string parseRequest(const std::string& data) { - return parseHttp(true, data); - } - - inline std::string parseResponse(const std::string& data, std::unordered_map& headers) { - return parseHttp(false, data, headers); - } - - inline std::string parseResponse(const std::string& data) { - return parseHttp(false, data); - } - -private: - std::string parseHttp(bool isRequest, const std::string& data, std::unordered_map& headers); - std::string parseHttp(bool isRequest, const std::string& data); + std::string generateRequest(const Url& url, const std::vector& args, bool isKeepAlive = false) const; + std::string generateMultipartFormData(const std::vector& args, const std::string& bondary) const; + std::string generateMultipartBoundary(const std::vector& args) const; + std::string generateWwwFormUrlencoded(const std::vector& args) const; + std::string generateResponse(const std::string& data, const std::string& mimeType, unsigned short statusCode, const std::string& statusStr, bool isKeepAlive) const; + std::unordered_map parseHeader(const std::string& data, bool isRequest) const; + std::string extractBody(const std::string& data) const; }; } -- cgit v1.2.3