optimize set_url/build_request in http_header.cpp

This commit is contained in:
shuxin   zheng 2021-08-19 10:13:05 +08:00
parent 7b5a36771c
commit 079f1eb069
2 changed files with 20 additions and 6 deletions

View File

@ -105,6 +105,13 @@
</content>
<content url="file://$MODULE_DIR$/../../include">
<sourceFolder url="file://$MODULE_DIR$/../../include" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/../../include/pgsql" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/../../include/sqlite" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/../../include/mysql" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/../../include/pgsql" />
<sourceFolder url="file://$MODULE_DIR$/../../include/sqlite" />
<sourceFolder url="file://$MODULE_DIR$/../../include/mysql" />
<sourceFolder url="file://$MODULE_DIR$/../../include" />
</content>
<content url="file://$MODULE_DIR$/../../include/mysql">
<sourceFolder url="file://$MODULE_DIR$/../../include/mysql" isTestSource="false" />
@ -117,7 +124,11 @@
</content>
<content url="file://$MODULE_DIR$/../../lib_acl">
<sourceFolder url="file://$MODULE_DIR$/../../lib_acl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/../../lib_acl/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/../../lib_acl/include" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/../../lib_acl/src" />
<sourceFolder url="file://$MODULE_DIR$/../../lib_acl/include" />
<sourceFolder url="file://$MODULE_DIR$/../../lib_acl" />
</content>
<content url="file://$MODULE_DIR$/../../lib_acl/include">
<sourceFolder url="file://$MODULE_DIR$/../../lib_acl/include" isTestSource="false" />
@ -127,6 +138,7 @@
</content>
<content url="file://$MODULE_DIR$/../../lib_acl_cpp/include">
<sourceFolder url="file://$MODULE_DIR$/../../lib_acl_cpp/include" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/../../lib_acl_cpp/include" />
</content>
<content url="file://$MODULE_DIR$/../../lib_acl_cpp/src">
<sourceFolder url="file://$MODULE_DIR$/../../lib_acl_cpp/src" isTestSource="false" />
@ -138,6 +150,7 @@
</content>
<content url="file://$MODULE_DIR$/../../lib_protocol/include">
<sourceFolder url="file://$MODULE_DIR$/../../lib_protocol/include" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/../../lib_protocol/include" />
</content>
<content url="file://$MODULE_DIR$/../../lib_protocol/src">
<sourceFolder url="file://$MODULE_DIR$/../../lib_protocol/src" isTestSource="false" />

View File

@ -887,20 +887,21 @@ bool http_header::build_request(string& buf) const
}
if (!params_.empty()) {
bool is_first;
bool first_param;
if (strchr(url_, '?') == NULL) {
buf << '?';
is_first = false;
first_param = true;
} else {
is_first = true;
first_param = false;
}
acl::string tmp;
std::list<HTTP_PARAM*>::const_iterator it = params_.begin();
for (; it != params_.end(); ++it) {
if (is_first) {
if (first_param) {
first_param = false;
} else {
buf += '&';
is_first = false;
}
}
// 需要对参数进行 URL 编码