mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-17 22:55:38 +00:00
Properly encoded parameters. Otherwise the query gets truncated.
This commit is contained in:
parent
3e1ecb4a84
commit
2999a8068a
|
@ -5,6 +5,28 @@
|
||||||
|
|
||||||
boost::asio::io_service HttpReq::io_service;
|
boost::asio::io_service HttpReq::io_service;
|
||||||
|
|
||||||
|
std::string HttpReq::urlEncode(const std::string &s)
|
||||||
|
{
|
||||||
|
const std::string unreserved = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.~";
|
||||||
|
|
||||||
|
std::string escaped="";
|
||||||
|
for(size_t i=0; i<s.length(); i++)
|
||||||
|
{
|
||||||
|
if (unreserved.find_first_of(s[i]) != std::string::npos)
|
||||||
|
{
|
||||||
|
escaped.push_back(s[i]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
escaped.append("%");
|
||||||
|
char buf[3];
|
||||||
|
sprintf(buf, "%.2X", s[i]);
|
||||||
|
escaped.append(buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return escaped;
|
||||||
|
}
|
||||||
|
|
||||||
HttpReq::HttpReq(const std::string& server, const std::string& path)
|
HttpReq::HttpReq(const std::string& server, const std::string& path)
|
||||||
: mResolver(io_service), mSocket(io_service), mStatus(REQ_IN_PROGRESS)
|
: mResolver(io_service), mSocket(io_service), mStatus(REQ_IN_PROGRESS)
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,6 +47,8 @@ public:
|
||||||
|
|
||||||
std::string getContent();
|
std::string getContent();
|
||||||
|
|
||||||
|
static std::string urlEncode(const std::string &s);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static boost::asio::io_service io_service;
|
static boost::asio::io_service io_service;
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ std::shared_ptr<HttpReq> GamesDBScraper::makeHttpReq(ScraperSearchParams params)
|
||||||
if(cleanName.empty())
|
if(cleanName.empty())
|
||||||
cleanName = params.game->getCleanName();
|
cleanName = params.game->getCleanName();
|
||||||
|
|
||||||
path += "name=" + cleanName;
|
path += "name=" + HttpReq::urlEncode(cleanName);
|
||||||
//platform TODO, should use some params.system get method
|
//platform TODO, should use some params.system get method
|
||||||
|
|
||||||
return std::make_shared<HttpReq>("thegamesdb.net", path);
|
return std::make_shared<HttpReq>("thegamesdb.net", path);
|
||||||
|
|
Loading…
Reference in a new issue