3 This file is part of libmsphttp
4 Copyright © 2008 Mikkosoft Productions, Mikko Rasa
5 Distributed under the LGPL
8 #include <msp/strings/formatter.h>
9 #include <msp/strings/utils.h>
17 Response::Response(Status s):
21 string Response::str() const
23 string result=format("%s %d %s\r\n", version_str(http_version), static_cast<int>(status), status);
29 Response Response::parse(const string &str)
33 unsigned lf=str.find('\n');
34 vector<string> parts=split(str.substr(0, lf), ' ', 2);
36 throw InvalidParameterValue("Invalid response");
38 result.http_version=parse_version(parts[0]);
39 result.status=static_cast<Status>(lexical_cast<unsigned>(parts[1]));
41 lf+=result.parse_headers(str.substr(lf+1));
43 result.parse_content(str.substr(lf+1));