| 595 | } |
| 596 | |
| 597 | void Http::Response::parseFields( std::istream& in ) { |
| 598 | std::string line; |
| 599 | while ( std::getline( in, line ) && ( line.size() > 2 ) ) { |
| 600 | std::string::size_type pos = line.find( ": " ); |
| 601 | |
| 602 | if ( pos != std::string::npos ) { |
| 603 | // Extract the field name and its value |
| 604 | std::string field = line.substr( 0, pos ); |
| 605 | std::string value = line.substr( pos + 2 ); |
| 606 | |
| 607 | // Remove any trailing \r |
| 608 | if ( !value.empty() && ( *value.rbegin() == '\r' ) ) |
| 609 | value.erase( value.size() - 1 ); |
| 610 | |
| 611 | // Add the field |
| 612 | mFields[String::toLower( field )] = value; |
| 613 | } |
| 614 | } |
| 615 | } |
| 616 | |
| 617 | static Http::Pool sGlobalHttpPool = Http::Pool(); |
| 618 | |