diff options
author | Egor Pugin <egor.pugin@gmail.com> | 2020-03-13 13:45:37 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-13 13:45:37 +0300 |
commit | dee88d3099607d6fa49e2775aaa8a6cb2d77d710 (patch) | |
tree | 74e5daa9a58f3a97b417925a212ac2cd31487a5e /src/net/HttpParser.cpp | |
parent | d1c6a8062577f5ce58105afff2d0a1887bfff957 (diff) | |
parent | 26fac5bf7e87dd5704a967ee4c744228b93d20b7 (diff) |
Merge pull request #129 from reo7sp/fix/use_proper_types
fix: use C++ fixed-width types instead of C types
Diffstat (limited to 'src/net/HttpParser.cpp')
-rw-r--r-- | src/net/HttpParser.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/net/HttpParser.cpp b/src/net/HttpParser.cpp index b83ddf0..8006c85 100644 --- a/src/net/HttpParser.cpp +++ b/src/net/HttpParser.cpp @@ -1,5 +1,8 @@ #include "tgbot/net/HttpParser.h" +#include <cstddef> +#include <cstdint> + #include <boost/algorithm/string.hpp> #include "tgbot/tools/StringTools.h" @@ -78,7 +81,7 @@ string HttpParser::generateMultipartFormData(const vector<HttpReqArg>& args, con string HttpParser::generateMultipartBoundary(const vector<HttpReqArg>& args) const { string result; - srand((uint32_t) time(nullptr)); + srand((std::uint32_t) time(nullptr)); for (const HttpReqArg& item : args) { if (item.isFile) { while (result.empty() || item.value.find(result) != string::npos) { @@ -131,10 +134,10 @@ string HttpParser::generateResponse(const string& data, const string& mimeType, unordered_map<string, string> HttpParser::parseHeader(const string& data, bool isRequest) const { unordered_map<string, string> headers; - size_t lineStart = 0; - size_t lineEnd = 0; - size_t lineSepPos = 0; - size_t lastLineEnd = string::npos; + std::size_t lineStart = 0; + std::size_t lineEnd = 0; + std::size_t lineSepPos = 0; + std::size_t lastLineEnd = string::npos; while (lastLineEnd != lineEnd) { lastLineEnd = lineEnd; bool isFirstLine = lineEnd == 0; @@ -165,7 +168,7 @@ unordered_map<string, string> HttpParser::parseHeader(const string& data, bool i } string HttpParser::extractBody(const string& data) const { - size_t headerEnd = data.find("\r\n\r\n"); + std::size_t headerEnd = data.find("\r\n\r\n"); if (headerEnd == string::npos) { return data; } |