diff options
author | Oleg Morozenkov <m@oleg.rocks> | 2018-07-23 02:35:50 +0300 |
---|---|---|
committer | Oleg Morozenkov <m@oleg.rocks> | 2018-07-23 02:35:50 +0300 |
commit | 98b8b7e4338b71ee46c4301b0bf2ae667be9a99d (patch) | |
tree | 32f8b0d32048b2d83b57773c0efa3db9600b8701 /include/tgbot/net/HttpParser.h | |
parent | 1dd3affe306793d2129f121c11e43c45ae8690da (diff) | |
parent | 167e3e7607e43a0f06c7f87ced94f481e6525b0e (diff) |
Merge branch 'master' into nicholascw-master
Diffstat (limited to 'include/tgbot/net/HttpParser.h')
-rw-r--r-- | include/tgbot/net/HttpParser.h | 34 |
1 files changed, 7 insertions, 27 deletions
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<HttpReqArg>& args, bool isKeepAlive = false); - std::string generateMultipartFormData(const std::vector<HttpReqArg>& args, const std::string& bondary); - std::string generateMultipartBoundary(const std::vector<HttpReqArg>& args); - std::string generateWwwFormUrlencoded(const std::vector<HttpReqArg>& 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<std::string, std::string>& 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<std::string, std::string>& 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<std::string, std::string>& headers); - std::string parseHttp(bool isRequest, const std::string& data); + std::string generateRequest(const Url& url, const std::vector<HttpReqArg>& args, bool isKeepAlive = false) const; + std::string generateMultipartFormData(const std::vector<HttpReqArg>& args, const std::string& bondary) const; + std::string generateMultipartBoundary(const std::vector<HttpReqArg>& args) const; + std::string generateWwwFormUrlencoded(const std::vector<HttpReqArg>& 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<std::string, std::string> parseHeader(const std::string& data, bool isRequest) const; + std::string extractBody(const std::string& data) const; }; } |