///////////////////////////////////////////////////////
| 269 | |
| 270 | //////////////////////////////////////////////////////////// |
| 271 | void Http::Response::parseFields(std::istream& in) |
| 272 | { |
| 273 | std::string line; |
| 274 | while (std::getline(in, line) && (line.size() > 2)) |
| 275 | { |
| 276 | const std::string::size_type pos = line.find(": "); |
| 277 | if (pos != std::string::npos) |
| 278 | { |
| 279 | // Extract the field name and its value |
| 280 | const std::string field = line.substr(0, pos); |
| 281 | std::string value = line.substr(pos + 2); |
| 282 | |
| 283 | // Remove any trailing \r |
| 284 | if (!value.empty() && (*value.rbegin() == '\r')) |
| 285 | value.erase(value.size() - 1); |
| 286 | |
| 287 | // Add the field |
| 288 | m_fields[toLower(field)] = value; |
| 289 | } |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | |
| 294 | //////////////////////////////////////////////////////////// |