mirror of
https://github.com/cocos/cocos-engine.git
synced 2026-09-07 00:02:53 +08:00
@@ -124,12 +124,20 @@ public:
|
||||
/* append custom headers one by one */
|
||||
for (auto &header : headers) {
|
||||
uint32_t len = header.length();
|
||||
uint32_t pos = header.find(':');
|
||||
if (-1 == pos || pos >= len) {
|
||||
ccstd::string::size_type pos = header.find(':');
|
||||
if (ccstd::string::npos == pos || pos >= len) {
|
||||
continue;
|
||||
}
|
||||
ccstd::string str1 = header.substr(0, pos);
|
||||
ccstd::string str2 = header.substr(pos + 1, len - pos - 1);
|
||||
ccstd::string str2 = header.substr(pos + 1);
|
||||
// trim \n at the end of the string
|
||||
if (!str2.empty() && str2[str2.size() - 1] == '\n') {
|
||||
str2.erase(str2.size() - 1);
|
||||
}
|
||||
// trim leading space (header is field: value format)
|
||||
if (!str2.empty() && str2[0] == ' ') {
|
||||
str2.erase(0, 1);
|
||||
}
|
||||
addRequestHeader(str1.c_str(), str2.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user