introduce string_view

This commit is contained in:
Chunting Gu
2021-06-17 18:58:53 +08:00
parent 751a3539ae
commit 26bb6b341a
38 changed files with 404 additions and 344 deletions
+8 -8
View File
@@ -128,7 +128,7 @@ void ClientSession::Stop() {
started_ = false;
}
void ClientSession::Accept(const std::string& content_types) {
void ClientSession::Accept(string_view content_types) {
if (!content_types.empty()) {
headers_.Set(headers::kAccept, content_types);
}
@@ -168,18 +168,18 @@ void ClientSession::AcceptGzip(bool gzip) {
#endif // WEBCC_ENABLE_GZIP
void ClientSession::Auth(const std::string& type,
const std::string& credentials) {
headers_.Set(headers::kAuthorization, type + " " + credentials);
void ClientSession::Auth(string_view type, string_view credentials) {
headers_.Set(headers::kAuthorization,
ToString(type) + " " + ToString(credentials));
}
void ClientSession::AuthBasic(const std::string& login,
const std::string& password) {
auto credentials = Base64Encode(login + ":" + password);
void ClientSession::AuthBasic(string_view login, string_view password) {
auto credentials =
Base64Encode(ToString(login) + ":" + ToString(password));
return Auth("Basic", credentials);
}
void ClientSession::AuthToken(const std::string& token) {
void ClientSession::AuthToken(string_view token) {
return Auth("Token", token);
}