X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Frequest.cpp;h=31e9c7c201959f158e6443556775d9bdfe4095eb;hb=2ced7606eb9090cdddd89e0481c441403d367bb2;hp=6bad3700681fefdffd40178a88e44cb146442e0b;hpb=f53eda26a3160972908f15c2427a60b0b82fbe87;p=libs%2Fnet.git diff --git a/source/request.cpp b/source/request.cpp index 6bad370..31e9c7c 100644 --- a/source/request.cpp +++ b/source/request.cpp @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of libmsphttp -Copyright © 2008 Mikkosoft Productions, Mikko Rasa -Distributed under the LGPL -*/ - #include #include #include @@ -23,23 +16,23 @@ Request::Request(const string &m, const string &p): string Request::str() const { - string result=format("%s %s %s\r\n", method, path, version_str(http_version)); - result+=str_common(); + string result = format("%s %s %s\r\n", method, path, version_str(http_version)); + result += str_common(); return result; } Request Request::parse(const string &str) { - unsigned lf=str.find('\n'); - vector parts=split(str.substr(0, lf-(str[lf-1]=='\r')), ' ', 2); + unsigned lf = str.find('\n'); + vector parts = split(str.substr(0, lf-(str[lf-1]=='\r')), ' ', 2); if(parts.size()<3) throw InvalidParameterValue("Invalid request"); Request result(parts[0], parts[1]); - result.http_version=parse_version(parts[2]); + result.http_version = parse_version(parts[2]); - lf+=result.parse_headers(str.substr(lf+1)); + lf += result.parse_headers(str.substr(lf+1)); result.parse_content(str.substr(lf+1)); @@ -48,16 +41,16 @@ Request Request::parse(const string &str) Request Request::from_url(const string &str) { - Url url=parse_url(str); + Url url = parse_url(str); if(url.scheme!="http") throw InvalidParameterValue("Only http scheme is supported"); - string path=url.path; + string path = url.path; if(path.empty()) - path="/"; + path = "/"; if(!url.query.empty()) { - path+='?'; - path+=url.query; + path += '?'; + path += url.query; } Request result("GET", path);