1 #include <msp/strings/format.h>
2 #include <msp/strings/utils.h>
10 Response::Response(Status s):
14 string Response::str() const
16 string result = format("%s %d %s\r\n", version_str(http_version), static_cast<int>(status), status);
17 result += str_common();
22 Response Response::parse(const string &str)
26 string::size_type lf = str.find('\n');
27 vector<string> parts = split(str.substr(0, lf), ' ', 2);
29 throw invalid_argument("Response::parse");
31 result.http_version = parse_version(parts[0]);
32 result.status = static_cast<Status>(lexical_cast<unsigned>(parts[1]));
34 lf += result.parse_headers(str.substr(lf+1));
36 result.parse_content(str.substr(lf+1));