fix GET /path?params

This commit is contained in:
proller 2016-11-19 03:07:15 +03:00
parent 02b4a4aded
commit 636cbe4323

View File

@ -48,26 +48,29 @@ ReadBufferFromHTTP::ReadBufferFromHTTP(
method = Poco::Net::HTTPRequest::HTTP_POST;
std::stringstream uri;
uri << "http://" << host << ":" << port << "/" << path;
std::stringstream path_params;
path_params << "/" << path;
bool first = true;
for (const auto & it : params)
{
uri << (first ? "?" : "&");
path_params << (first ? "?" : "&");
first = false;
String encoded_key;
String encoded_value;
Poco::URI::encode(it.first, "=&#", encoded_key);
Poco::URI::encode(it.second, "&#", encoded_value);
uri << encoded_key << "=" << encoded_value;
path_params << encoded_key << "=" << encoded_value;
}
uri << "http://" << host << ":" << port << path_params.str();
session.setHost(resolveHost(host).toString()); /// Cache DNS forever (until server restart)
session.setPort(port);
session.setTimeout(connection_timeout, send_timeout, receive_timeout);
Poco::Net::HTTPRequest request(method, "/" + path);
Poco::Net::HTTPRequest request(method, path_params.str());
Poco::Net::HTTPResponse response;
LOG_TRACE((&Logger::get("ReadBufferFromHTTP")), "Sending request to " << uri.str());