From 8c4ac1a6f0e154ebcbc72e196d24df322da673bc Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 22 Jan 2015 16:20:00 +0200 Subject: [PATCH 1/1] Make Request API consistent with itself and others Request::from_url was incorrectly creating requests with unencoded URLs. --- source/http/request.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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()) -- 2.45.2