http: don't encode whole url

url encoding should be used for url components
by users of the library,
otherwise characters like '/' get escaped.
This commit is contained in:
Adrien Béraud committed 2023-08-30 17:58:45 -04:00
1 parent 21fd58a39c
commit 55688a25aa
2 files changed
+4 -4

No files matched your search

+1 -1
View File
@@ -330,7 +330,7 @@ private:
void build();
static std::string url_encode(const std::string& value);
static std::string url_encode(std::string_view value);
void init_default_headers();
/**
+3 -3
View File
@@ -1052,7 +1052,7 @@ Request::build()
bool append_body = !body_.empty();
// first header
request << header_.method().c_str() << " " << url_encode(header_.request_target()) << " " <<
request << header_.method().c_str() << " " << header_.request_target() << " " <<
"HTTP/" << header_.http_major() << "." << header_.http_minor() << "\r\n";
// other headers
@@ -1090,7 +1090,7 @@ Request::build()
// https://stackoverflow.com/a/17708801
std::string
Request::url_encode(const std::string& value)
Request::url_encode(std::string_view value)
{
std::ostringstream escaped;
escaped.fill('0');
@@ -1317,7 +1317,7 @@ Request::post()
init_parser();
if (logger_)
logger_->d("[http:request:%i] sending %zu bytes", id_, request_.size());
logger_->debug("[http:request:{}] sending {} bytes", id_, request_.size());
// write the request to buffer
std::ostream request_stream(&conn_->input());