From: Mikko Rasa Date: Thu, 22 Jan 2015 14:20:00 +0000 (+0200) Subject: Make Request API consistent with itself and others X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=8c4ac1a6f0e154ebcbc72e196d24df322da673bc;p=libs%2Fnet.git Make Request API consistent with itself and others Request::from_url was incorrectly creating requests with unencoded URLs. --- diff --git a/source/http/request.cpp b/source/http/request.cpp index 0194859..f050e04 100644 --- a/source/http/request.cpp +++ b/source/http/request.cpp @@ -12,7 +12,10 @@ namespace Http { Request::Request(const string &m, const string &p): method(m), path(p) -{ } +{ + if(path.find(' ')!=string::npos) + throw invalid_argument("Request::Request"); +} string Request::str() const { @@ -45,7 +48,7 @@ Request Request::from_url(const string &str) if(url.scheme!="http") throw invalid_argument("Request::from_url"); - string path = url.path; + string path = urlencode(url.path); if(path.empty()) path = "/"; if(!url.query.empty())