simplify string utilities

This commit is contained in:
Chunting Gu
2021-04-19 14:01:18 +08:00
parent f5f72d7897
commit 01210e8a42
16 changed files with 150 additions and 191 deletions
+6 -5
View File
@@ -1,6 +1,7 @@
#include <fstream>
#include <iostream>
#include "boost/algorithm/string.hpp"
#include "boost/filesystem/fstream.hpp"
#include "boost/filesystem/operations.hpp"
@@ -299,7 +300,7 @@ TEST(ClientTest, Post) {
static bfs::path GenerateTempFile(const std::string& data) {
try {
bfs::path path = bfs::temp_directory_path() / webcc::random_string(10);
bfs::path path = bfs::temp_directory_path() / webcc::RandomString(10);
bfs::ofstream ofs;
ofs.open(path, std::ios::binary);
@@ -419,24 +420,24 @@ TEST(ClientTest, KeepAlive) {
// Keep-Alive by default.
auto r = session.Send(webcc::RequestBuilder{}.Get(url)());
EXPECT_TRUE(webcc::iequals(r->GetHeader("Connection"), "Keep-alive"));
EXPECT_TRUE(boost::iequals(r->GetHeader("Connection"), "Keep-alive"));
// Close by setting Connection header directly.
r = session.Send(webcc::RequestBuilder{}.Get(url).
Header("Connection", "Close")
());
EXPECT_TRUE(webcc::iequals(r->GetHeader("Connection"), "Close"));
EXPECT_TRUE(boost::iequals(r->GetHeader("Connection"), "Close"));
// Close by using request builder.
r = session.Send(webcc::RequestBuilder{}.Get(url).KeepAlive(false)());
EXPECT_TRUE(webcc::iequals(r->GetHeader("Connection"), "Close"));
EXPECT_TRUE(boost::iequals(r->GetHeader("Connection"), "Close"));
// Keep-Alive explicitly by using request builder.
r = session.Send(webcc::RequestBuilder{}.Get(url).KeepAlive(true)());
EXPECT_TRUE(webcc::iequals(r->GetHeader("Connection"), "Keep-alive"));
EXPECT_TRUE(boost::iequals(r->GetHeader("Connection"), "Keep-alive"));
} catch (const webcc::Error& error) {
std::cerr << error << std::endl;