Open dodng opened 6 years ago
您的Split函数实现如下: inline void Split(const string& src, vector& res, const string& pattern, size_t maxsplit = string::npos) { res.clear(); size_t Start = 0; size_t end = 0; string sub; while(Start < src.size()) { end = src.find_first_of(pattern, Start); if(string::npos == end || res.size() >= maxsplit) { sub = src.substr(Start); res.push_back(sub); return; } sub = src.substr(Start, end - Start); res.push_back(sub); Start = end + 1; } return; }
我拿来做http解析的时候发现功能异常。 示例数据如下: src: http\r\nlength\r\n\r\nhttp_body\r\n
pattern: \r\n\r\n
res: http length http_body
This issue has not been updated for over 5 years and will be marked as stale. If the issue still exists, please comment or update the issue, otherwise it will be closed after 7 days.
您的Split函数实现如下: inline void Split(const string& src, vector& res, const string& pattern, size_t maxsplit = string::npos) {
res.clear();
size_t Start = 0;
size_t end = 0;
string sub;
while(Start < src.size()) {
end = src.find_first_of(pattern, Start);
if(string::npos == end || res.size() >= maxsplit) {
sub = src.substr(Start);
res.push_back(sub);
return;
}
sub = src.substr(Start, end - Start);
res.push_back(sub);
Start = end + 1;
}
return;
}
我拿来做http解析的时候发现功能异常。 示例数据如下: src: http\r\nlength\r\n\r\nhttp_body\r\n
pattern: \r\n\r\n
res: http length http_body