]> git.tdb.fi Git - libs/net.git/commitdiff
Make Request API consistent with itself and others
authorMikko Rasa <tdb@tdb.fi>
Thu, 22 Jan 2015 14:20:00 +0000 (16:20 +0200)
committerMikko Rasa <tdb@tdb.fi>
Thu, 22 Jan 2015 14:20:00 +0000 (16:20 +0200)
Request::from_url was incorrectly creating requests with unencoded URLs.

source/http/request.cpp

index 01948592ef9c8033119bf86bfbf1ff40c66307f7..f050e0440084d0a0b447875fec014d7ef4940dee 100644 (file)
@@ -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())