diff options
Diffstat (limited to 'include/tgbot/net')
-rw-r--r-- | include/tgbot/net/HttpParser.h | 8 | ||||
-rw-r--r-- | include/tgbot/net/HttpServer.h | 4 | ||||
-rw-r--r-- | include/tgbot/net/TgWebhookServer.h | 2 |
3 files changed, 7 insertions, 7 deletions
diff --git a/include/tgbot/net/HttpParser.h b/include/tgbot/net/HttpParser.h index ec4c077..d40619a 100644 --- a/include/tgbot/net/HttpParser.h +++ b/include/tgbot/net/HttpParser.h @@ -24,7 +24,7 @@ #define TGBOT_HTTPPARSER_H #include <string> -#include <map> +#include <unordered_map> #include <vector> #include "tgbot/net/Url.h" @@ -43,7 +43,7 @@ public: 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::map<std::string, std::string>& headers) { + inline std::string parseRequest(const std::string& data, std::unordered_map<std::string, std::string>& headers) { return parseHttp(true, data, headers); } @@ -51,7 +51,7 @@ public: return parseHttp(true, data); } - inline std::string parseResponse(const std::string& data, std::map<std::string, std::string>& headers) { + inline std::string parseResponse(const std::string& data, std::unordered_map<std::string, std::string>& headers) { return parseHttp(false, data, headers); } @@ -60,7 +60,7 @@ public: } private: - std::string parseHttp(bool isRequest, const std::string& data, std::map<std::string, std::string>& headers); + 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); }; diff --git a/include/tgbot/net/HttpServer.h b/include/tgbot/net/HttpServer.h index e760e29..34cd9c7 100644 --- a/include/tgbot/net/HttpServer.h +++ b/include/tgbot/net/HttpServer.h @@ -43,7 +43,7 @@ protected: class Connection; public: - typedef std::function<std::string (const std::string&, const std::map<std::string, std::string>)> ServerHandler; + typedef std::function<std::string (const std::string&, const std::unordered_map<std::string, std::string>)> ServerHandler; HttpServer(std::shared_ptr<boost::asio::basic_socket_acceptor<Protocol>> acceptor, const ServerHandler& handler) : _acceptor(acceptor), _handler(handler) { } @@ -80,7 +80,7 @@ protected: void start() { data.reserve(10240); socket->async_receive(data, [this]() { - std::map<std::string, std::string> headers; + std::unordered_map<std::string, std::string> headers; std::string body = HttpParser::getInstance().parseResponse(data, headers); socket->async_send(_handler(body, headers)); }); diff --git a/include/tgbot/net/TgWebhookServer.h b/include/tgbot/net/TgWebhookServer.h index 9352e82..696d126 100644 --- a/include/tgbot/net/TgWebhookServer.h +++ b/include/tgbot/net/TgWebhookServer.h @@ -37,7 +37,7 @@ public: TgWebhookServer(std::shared_ptr<boost::asio::basic_socket_acceptor<Protocol>> acceptor, const typename HttpServer<Protocol>::ServerHandler& handler) = delete; TgWebhookServer(std::shared_ptr<boost::asio::basic_socket_acceptor<Protocol>> acceptor, const std::string& path, const EventHandler* eventHandler) : - HttpServer<Protocol>(acceptor, [eventHandler, &path](const std::string& data, const std::map<std::string, std::string>& headers) -> std::string { + HttpServer<Protocol>(acceptor, [eventHandler, &path](const std::string& data, const std::unordered_map<std::string, std::string>& headers) -> std::string { if (headers.at("method") == "POST" && headers.at("path") == path) { eventHandler->handleUpdate(TgTypeParser::getInstance().parseJsonAndGetUpdate(TgTypeParser::getInstance().parseJson(data))); } |