Fix content-type parsing issue; refine http parser.

This commit is contained in:
Chunting Gu
2019-04-15 12:53:43 +08:00
parent 5e1b14e74d
commit df4bb33bd8
9 changed files with 76 additions and 51 deletions
+11 -1
View File
@@ -142,7 +142,17 @@ bool ContentType::Valid() const {
void ContentType::Init(const std::string& str) {
std::string other;
Split2(str, ';', &media_type_, &other);
std::size_t pos = str.find(';');
if (pos == std::string::npos) {
media_type_ = str;
} else {
media_type_ = str.substr(0, pos);
other = str.substr(pos + 1);
}
boost::trim(media_type_);
boost::trim(other);
if (media_type_ == "multipart/form-data") {
multipart_ = true;