don't use boost string algorithm

This commit is contained in:
Chunting Gu
2020-02-18 09:49:45 +08:00
parent 7e7ab1c1e8
commit 1e3c2b2604
25 changed files with 336 additions and 308 deletions
+7 -9
View File
@@ -1,7 +1,5 @@
#include "webcc/parser.h"
#include "boost/algorithm/string.hpp"
#include "webcc/logger.h"
#include "webcc/message.h"
#include "webcc/string.h"
@@ -71,7 +69,7 @@ bool FileBodyHandler::OpenFile() {
// Generate a random string as file name.
// A replacement of boost::filesystem::unique_path().
temp_path_ /= string::RandomString(10);
temp_path_ /= random_string(10);
LOG_VERB("Generate a temp path for streaming: %s",
temp_path_.string().c_str());
@@ -252,16 +250,16 @@ bool Parser::GetNextLine(std::size_t off, std::string* line, bool erase) {
bool Parser::ParseHeaderLine(const std::string& line) {
Header header;
if (!utility::SplitKV(line, ':', &header.first, &header.second)) {
if (!split_kv(header.first, header.second, line, ':')) {
LOG_ERRO("Invalid header: %s", line.c_str());
return false;
}
if (boost::iequals(header.first, headers::kContentLength)) {
if (iequals(header.first, headers::kContentLength)) {
content_length_parsed_ = true;
std::size_t content_length = kInvalidLength;
if (!utility::ToSize(header.second, 10, &content_length)) {
if (!to_size_t(header.second, 10, &content_length)) {
LOG_ERRO("Invalid content length: %s.", header.second.c_str());
return false;
}
@@ -269,13 +267,13 @@ bool Parser::ParseHeaderLine(const std::string& line) {
LOG_INFO("Content length: %u.", content_length);
content_length_ = content_length;
} else if (boost::iequals(header.first, headers::kContentType)) {
} else if (iequals(header.first, headers::kContentType)) {
content_type_.Parse(header.second);
if (!content_type_.Valid()) {
LOG_ERRO("Invalid content-type header: %s", header.second.c_str());
return false;
}
} else if (boost::iequals(header.first, headers::kTransferEncoding)) {
} else if (iequals(header.first, headers::kTransferEncoding)) {
if (header.second == "chunked") {
// The content is chunked.
chunked_ = true;
@@ -394,7 +392,7 @@ bool Parser::ParseChunkSize() {
hex_str = line;
}
if (!utility::ToSize(hex_str, 16, &chunk_size_)) {
if (!to_size_t(hex_str, 16, &chunk_size_)) {
LOG_ERRO("Invalid chunk-size: %s.", hex_str.c_str());
return false;
}