summaryrefslogtreecommitdiff
path: root/include/tgbot/net/HttpParser.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/tgbot/net/HttpParser.h')
-rw-r--r--include/tgbot/net/HttpParser.h34
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;
};
}