From 806e7e5a3edf4fdf2b9c48469a7bc23307b200b0 Mon Sep 17 00:00:00 2001 From: Alexander Zaitsev Date: Fri, 13 Mar 2020 03:46:58 +0300 Subject: fix: use C++ fixed-width types instead of C types - C++ standard doesn't guarantee that C-types without std namespace are available in global namespace. So the proper solution (since it's C++ library) is using C++ types instead of C Tested: - Local build - By unit-tests --- src/net/HttpParser.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/net/HttpParser.cpp') diff --git a/src/net/HttpParser.cpp b/src/net/HttpParser.cpp index b83ddf0..386a4d9 100644 --- a/src/net/HttpParser.cpp +++ b/src/net/HttpParser.cpp @@ -1,5 +1,7 @@ #include "tgbot/net/HttpParser.h" +#include + #include #include "tgbot/tools/StringTools.h" @@ -78,7 +80,7 @@ string HttpParser::generateMultipartFormData(const vector& args, con string HttpParser::generateMultipartBoundary(const vector& 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) { -- cgit v1.2.3 From 26fac5bf7e87dd5704a967ee4c744228b93d20b7 Mon Sep 17 00:00:00 2001 From: Alexander Zaitsev Date: Fri, 13 Mar 2020 03:56:35 +0300 Subject: fix: use std::size_t instead of size_t - use C++ size_t from std namespace instead of a version from global namespace Tested: - Local build - Unit-tests --- src/net/HttpParser.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/net/HttpParser.cpp') diff --git a/src/net/HttpParser.cpp b/src/net/HttpParser.cpp index 386a4d9..8006c85 100644 --- a/src/net/HttpParser.cpp +++ b/src/net/HttpParser.cpp @@ -1,5 +1,6 @@ #include "tgbot/net/HttpParser.h" +#include #include #include @@ -133,10 +134,10 @@ string HttpParser::generateResponse(const string& data, const string& mimeType, unordered_map HttpParser::parseHeader(const string& data, bool isRequest) const { unordered_map 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; @@ -167,7 +168,7 @@ unordered_map 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; } -- cgit v1.2.3