优化函数命名风格

FindField改名为findSubString
This commit is contained in:
xia-chu
2023-06-10 12:28:49 +08:00
committed by 夏楚
parent 31944a92ad
commit 64b8079ac1
17 changed files with 51 additions and 50 deletions

View File

@@ -21,7 +21,7 @@ namespace mediakit {
void HttpClient::sendRequest(const string &url) {
clearResponse();
_url = url;
auto protocol = FindField(url.data(), NULL, "://");
auto protocol = findSubString(url.data(), NULL, "://");
uint16_t port;
bool is_https;
if (strcasecmp(protocol.data(), "http") == 0) {
@@ -35,11 +35,11 @@ void HttpClient::sendRequest(const string &url) {
throw std::invalid_argument(strErr);
}
auto host = FindField(url.data(), "://", "/");
auto host = findSubString(url.data(), "://", "/");
if (host.empty()) {
host = FindField(url.data(), "://", NULL);
host = findSubString(url.data(), "://", NULL);
}
_path = FindField(url.data(), host.data(), NULL);
_path = findSubString(url.data(), host.data(), NULL);
if (_path.empty()) {
_path = "/";
}
@@ -361,8 +361,8 @@ void HttpClient::checkCookie(HttpClient::HttpHeader &headers) {
int index = 0;
auto arg_vec = split(it_set_cookie->second, ";");
for (string &key_val : arg_vec) {
auto key = FindField(key_val.data(), NULL, "=");
auto val = FindField(key_val.data(), "=", NULL);
auto key = findSubString(key_val.data(), NULL, "=");
auto val = findSubString(key_val.data(), "=", NULL);
if (index++ == 0) {
cookie->setKeyVal(key, val);

View File

@@ -158,9 +158,9 @@ HttpServerCookie::Ptr HttpCookieManager::getCookie(const string &cookie_name, co
if (it == http_header.end()) {
return nullptr;
}
auto cookie = FindField(it->second.data(), (cookie_name + "=").data(), ";");
auto cookie = findSubString(it->second.data(), (cookie_name + "=").data(), ";");
if (cookie.empty()) {
cookie = FindField(it->second.data(), (cookie_name + "=").data(), nullptr);
cookie = findSubString(it->second.data(), (cookie_name + "=").data(), nullptr);
}
if (cookie.empty()) {
return nullptr;

View File

@@ -600,8 +600,8 @@ void HttpResponseInvokerImp::responseFile(const StrCaseMap &requestHeader,
if (!strRange.empty()) {
//分节下载
code = 206;
auto iRangeStart = atoll(FindField(strRange.data(), "bytes=", "-").data());
auto iRangeEnd = atoll(FindField(strRange.data(), "-", nullptr).data());
auto iRangeStart = atoll(findSubString(strRange.data(), "bytes=", "-").data());
auto iRangeEnd = atoll(findSubString(strRange.data(), "-", nullptr).data());
auto fileSize = fileBody->remainSize();
if (iRangeEnd == 0) {
iRangeEnd = fileSize - 1;